Backport big tree benchmarks to 0.1
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 = "random")]
30pub mod randomizable;
31
32#[cfg(feature = "std")]
33use core::fmt::{Display, Formatter, Result};
34
35/// An error that can occur when performing layout
36#[derive(Debug)]
37pub enum Error {
38 /// The [`Node`](node::Node) was invalid
39 InvalidNode(node::Node),
40}
41
42#[cfg(feature = "std")]
43impl Display for Error {
44 fn fmt(&self, f: &mut Formatter) -> Result {
45 match *self {
46 Error::InvalidNode(ref node) => write!(f, "Invalid node {:?}", node),
47 }
48 }
49}
50
51#[cfg(feature = "std")]
52impl std::error::Error for Error {
53 fn description(&self) -> &str {
54 match *self {
55 Error::InvalidNode(_) => "The node is not part of the Taffy instance",
56 }
57 }
58}