gioser

tawasuyu/taffy

A high performance rust-powered UI layout library

HTML 5364Rust 86Markdown 12TOML 91841 Definiciones

⎇ 0.1.x src/lib.rs Rust · 58 líneas · 1.3 KB Historia Quién tocó qué crudo

Disable super-deep benchmarks (0.1 is too slow to complete these at all) (#280) 7db11fa87 · Nico Burns ·

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}