gioser

tawasuyu/taffy

A high performance rust-powered UI layout library

Rust 976HTML 921Markdown 12TOML 82979 Definiciones

⎇ 39cd0fcbbda7cd38cc6316e7339b1f3aed29e99f src/lib.rs Rust · 55 líneas · 1.2 KB Historia Quién tocó qué crudo

Rename sprawl to taffy (#134) 42d1838d3 · Alice Cecile ·

1#![doc = include_str!("../README.md")]
2#![cfg_attr(not(feature = "std"), no_std)]
3#![deny(unsafe_code)]
4#![warn(missing_docs)]
5#![warn(clippy::missing_docs_in_private_items)]
6
7#[cfg(all(not(feature = "std"), feature = "alloc"))]
8extern crate alloc;
9
10#[cfg_attr(feature = "serde", macro_use)]
11#[cfg(feature = "serde")]
12extern crate serde;
13
14pub mod geometry;
15pub mod layout;
16pub mod node;
17pub mod number;
18pub mod prelude;
19pub mod style;
20
21mod flexbox;
22mod forest;
23#[cfg(all(not(feature = "alloc"), not(feature = "std")))]
24mod indexmap;
25mod sys;
26
27pub use crate::node::Taffy;
28
29#[cfg(feature = "std")]
30use core::fmt::{Display, Formatter, Result};
31
32/// An error that can occur when performing layout
33#[derive(Debug)]
34pub enum Error {
35    /// The [`Node`](node::Node) was invalid
36    InvalidNode(node::Node),
37}
38
39#[cfg(feature = "std")]
40impl Display for Error {
41    fn fmt(&self, f: &mut Formatter) -> Result {
42        match *self {
43            Error::InvalidNode(ref node) => write!(f, "Invalid node {:?}", node),
44        }
45    }
46}
47
48#[cfg(feature = "std")]
49impl std::error::Error for Error {
50    fn description(&self) -> &str {
51        match *self {
52            Error::InvalidNode(_) => "The node is not part of the Taffy instance",
53        }
54    }
55}