Add CI jobs for checking and testing with no default features (#36)
1#[cfg(feature = "std")]
2mod std {
3 pub type Box<A> = ::std::boxed::Box<A>;
4 pub type Map<K, V> = ::std::collections::HashMap<K, V>;
5 pub type Vec<A> = ::std::vec::Vec<A>;
6 pub type ChildrenVec<A> = ::std::vec::Vec<A>;
7 pub type ParentsVec<A> = ::std::vec::Vec<A>;
8
9 pub fn new_map_with_capacity<K, V>(capacity: usize) -> Map<K, V>
10 where
11 K: Eq + ::std::hash::Hash,
12 {
13 Map::with_capacity(capacity)
14 }
15
16 pub fn new_vec_with_capacity<A>(capacity: usize) -> Vec<A> {
17 Vec::with_capacity(capacity)
18 }
19
20 #[inline]
21 pub fn round(value: f32) -> f32 {
22 value.round()
23 }
24
25 #[inline]
26 pub fn abs(value: f32) -> f32 {
27 value.abs()
28 }
29}
30
31#[cfg(feature = "alloc")]
32mod alloc {
33 pub type Box<A> = ::alloc::boxed::Box<A>;
34 pub type Map<K, V> = ::hashbrown::HashMap<K, V>;
35 pub type Vec<A> = ::alloc::vec::Vec<A>;
36 pub type ChildrenVec<A> = ::alloc::vec::Vec<A>;
37 pub type ParentsVec<A> = ::alloc::vec::Vec<A>;
38
39 pub fn new_map_with_capacity<K, V>(capacity: usize) -> Map<K, V> {
40 Map::with_capacity(capacity)
41 }
42
43 pub fn new_vec_with_capacity<A>(capacity: usize) -> Vec<A> {
44 Vec::with_capacity(capacity)
45 }
46
47 #[inline]
48 pub fn round(value: f32) -> f32 {
49 num_traits::float::FloatCore::round(value)
50 }
51
52 #[inline]
53 pub fn abs(value: f32) -> f32 {
54 num_traits::float::FloatCore::abs(value)
55 }
56}
57
58#[cfg(all(not(feature = "alloc"), not(feature = "std")))]
59mod core {
60 const MAX_NODE_COUNT: usize = 256;
61 const MAX_CHILD_COUNT: usize = 16;
62 const MAX_PARENTS_COUNT: usize = 1;
63
64 pub type Map<K, V> = ::heapless::FnvIndexMap<K, V, MAX_NODE_COUNT>;
65 pub type Vec<A> = ::arrayvec::ArrayVec<A, MAX_NODE_COUNT>;
66 pub type ChildrenVec<A> = ::arrayvec::ArrayVec<A, MAX_CHILD_COUNT>;
67 pub type ParentsVec<A> = ::arrayvec::ArrayVec<A, MAX_PARENTS_COUNT>;
68
69 pub fn new_map_with_capacity<K, V>(_capacity: usize) -> Map<K, V>
70 where
71 K: Eq + ::hash32::Hash,
72 {
73 Map::new()
74 }
75
76 pub fn new_vec_with_capacity<A, const CAP: usize>(_capacity: usize) -> ::arrayvec::ArrayVec<A, CAP> {
77 ::arrayvec::ArrayVec::new()
78 }
79
80 #[inline]
81 pub fn round(value: f32) -> f32 {
82 num_traits::float::FloatCore::round(value)
83 }
84
85 #[inline]
86 pub fn abs(value: f32) -> f32 {
87 num_traits::float::FloatCore::abs(value)
88 }
89}
90
91#[cfg(feature = "alloc")]
92pub use self::alloc::*;
93#[cfg(all(not(feature = "alloc"), not(feature = "std")))]
94pub use self::core::*;
95#[cfg(feature = "std")]
96pub use self::std::*;