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