pub trait RTreeNum:
Bounded
+ Num
+ Clone
+ Copy
+ Signed
+ PartialOrd
+ Debug { }
Expand description
Defines a number type that is compatible with rstar.
rstar works out of the box with the following standard library types:
- i8, i16, i32, i64, i128, isize
- Wrapping versions of the above
- f32, f64
This type cannot be implemented directly. Instead, it is required to implement
all required traits from the num_traits
crate.
§Example
use num_traits::{Bounded, Num, Signed};
#[derive(Clone, Copy, PartialEq, PartialOrd, Debug)]
struct MyFancyNumberType(f32);
impl num_traits::Bounded for MyFancyNumberType {
// ... details hidden ...
}
impl Signed for MyFancyNumberType {
// ... details hidden ...
}
impl Num for MyFancyNumberType {
// ... details hidden ...
}
// Lots of traits are still missing to make the above code compile, but
// let's assume they're implemented. `MyFancyNumberType` type now readily implements
// RTreeNum and can be used with r-trees:
use rstar::RTree;
let mut rtree = RTree::new();
rtree.insert([MyFancyNumberType(0.0), MyFancyNumberType(0.0)]);
Dyn Compatibility§
This trait is not dyn compatible.
In older versions of Rust, dyn compatibility was called "object safety", so this trait is not object safe.