Expand description
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 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 ...
}
// 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)]);