[−][src]Trait rstar::RTreeNum
Defines a number type that is compatible with rstar.
rstar works out of the box with the following standard library types:
- i32
- i64
- f32
- f64
This type cannot be implemented directly. Instead, it is just 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 Bounded for MyFancyNumberType { // ... details hidden ... } impl Signed for MyFancyNumberType { // ... details hidden ... } impl Num for MyFancyNumberType { // ... details hidden ... } // There's a lot of traits that are still missing to make the above code compile, // let's assume they are 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)]);