gioser

tawasuyu/taffy

A high performance rust-powered UI layout library

HTML 229Rust 8TOML 3CSS 1310 Definiciones

⎇ 2dc69edb30b0ea2efa66596d02bbc289896edbfc src/lib.rs Rust · 47 líneas · 937 B Historia Quién tocó qué crudo

Forbid unsafe code (#34) 55302f3fa · TimJentzsch ·

1#![cfg_attr(not(feature = "std"), no_std)]
2#![forbid(unsafe_code)]
3
4#[cfg(all(not(feature = "std"), feature = "alloc"))]
5extern crate alloc;
6
7#[cfg_attr(feature = "serde", macro_use)]
8#[cfg(feature = "serde")]
9extern crate serde;
10
11pub mod geometry;
12pub mod node;
13pub mod number;
14pub mod prelude;
15pub mod result;
16pub mod style;
17
18mod algo;
19mod forest;
20mod id;
21
22mod sys;
23
24pub use crate::node::Stretch;
25
26#[derive(Debug)]
27pub enum Error {
28    InvalidNode(node::Node),
29}
30
31#[cfg(feature = "std")]
32impl std::fmt::Display for Error {
33    fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result {
34        match *self {
35            Error::InvalidNode(ref node) => write!(f, "Invalid node {:?}", node),
36        }
37    }
38}
39
40#[cfg(feature = "std")]
41impl std::error::Error for Error {
42    fn description(&self) -> &str {
43        match *self {
44            Error::InvalidNode(_) => "The node is not part of the stretch instance",
45        }
46    }
47}