gioser

tawasuyu/taffy

A high performance rust-powered UI layout library

HTML 5364Rust 86Markdown 12TOML 91841 Definitions

⎇ 4c14991d8cb32e0b8f87b0dde48035a1d493331d src/lib.rs Rust · 46 lines · 913 B History Who touched what raw

added prelude + some refactoring 4c14991d8 · Adam Nemecek ·

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