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