diff --git a/rstar/CHANGELOG.md b/rstar/CHANGELOG.md index 141ffa6..8676fd5 100644 --- a/rstar/CHANGELOG.md +++ b/rstar/CHANGELOG.md @@ -4,6 +4,8 @@ - Add optional support for the [mint](https://docs.rs/mint/0.5.9/mint/index.html) crate - Implemented `IntoIter` for `RTree`, i.e. added a owning iterator - Added cached envelope bulk load benchmark +- Implemented `Hash` for `AABB`, `Line`, and `Rectangle`, provided the `Point` used implements `Hash` itself +- Implemented `Default` for `DefaultParams` ## Changed - Fixed a stack overflow error in `DrainIterator::next` diff --git a/rstar/src/aabb.rs b/rstar/src/aabb.rs index 7372e1a..c1a3ecb 100644 --- a/rstar/src/aabb.rs +++ b/rstar/src/aabb.rs @@ -18,7 +18,7 @@ use serde::{Deserialize, Serialize}; /// # Type arguments /// `P`: The struct is generic over which point type is used. Using an n-dimensional point /// type will result in an n-dimensional bounding box. -#[derive(Clone, Debug, Copy, PartialEq, Eq, Ord, PartialOrd)] +#[derive(Clone, Debug, Copy, PartialEq, Eq, Ord, PartialOrd, Hash)] #[cfg_attr(feature = "serde", derive(Serialize, Deserialize))] pub struct AABB

where diff --git a/rstar/src/params.rs b/rstar/src/params.rs index 64c0e66..03c2777 100644 --- a/rstar/src/params.rs +++ b/rstar/src/params.rs @@ -57,7 +57,7 @@ pub trait RTreeParams: Send + Sync { } /// The default parameters used when creating an r-tree without specific parameters. -#[derive(Clone, Copy, PartialEq, Eq)] +#[derive(Clone, Copy, PartialEq, Eq, Default)] pub struct DefaultParams; impl RTreeParams for DefaultParams { diff --git a/rstar/src/point.rs b/rstar/src/point.rs index ee419ef..e6d2e5e 100644 --- a/rstar/src/point.rs +++ b/rstar/src/point.rs @@ -4,10 +4,9 @@ use num_traits::{Bounded, Num, Signed, Zero}; /// 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 +/// - i8, i16, i32, i64, i128, isize +/// - [Wrapping](core::num::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. @@ -397,6 +396,27 @@ impl_point_for_tuple!(0 => a, 1 => b, 2 => c, 3 => d, 4 => e, 5 => f, 6 => g, 7 #[cfg(test)] mod tests { use super::*; + use core::num::Wrapping; + + #[test] + fn test_types() { + fn assert_impl_rtreenum() {} + + assert_impl_rtreenum::(); + assert_impl_rtreenum::(); + assert_impl_rtreenum::(); + assert_impl_rtreenum::(); + assert_impl_rtreenum::(); + assert_impl_rtreenum::(); + assert_impl_rtreenum::>(); + assert_impl_rtreenum::>(); + assert_impl_rtreenum::>(); + assert_impl_rtreenum::>(); + assert_impl_rtreenum::>(); + assert_impl_rtreenum::>(); + assert_impl_rtreenum::(); + assert_impl_rtreenum::(); + } macro_rules! test_tuple_configuration { ($($index:expr),*) => { diff --git a/rstar/src/primitives/line.rs b/rstar/src/primitives/line.rs index e317421..8999268 100644 --- a/rstar/src/primitives/line.rs +++ b/rstar/src/primitives/line.rs @@ -22,7 +22,7 @@ use num_traits::{One, Zero}; /// /// assert!(tree.contains(&line_1)); /// ``` -#[derive(Debug, Clone, Copy, Eq, PartialEq, Ord, PartialOrd)] +#[derive(Debug, Clone, Copy, Eq, PartialEq, Ord, PartialOrd, Hash)] #[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))] pub struct Line

where diff --git a/rstar/src/primitives/rectangle.rs b/rstar/src/primitives/rectangle.rs index da4c907..6e1d0ba 100644 --- a/rstar/src/primitives/rectangle.rs +++ b/rstar/src/primitives/rectangle.rs @@ -12,7 +12,7 @@ use crate::point::{Point, PointExt}; /// /// # Type parameters /// `P`: The rectangle's [Point] type. -#[derive(Debug, Clone, Copy, Eq, PartialEq, Ord, PartialOrd)] +#[derive(Debug, Clone, Copy, Eq, PartialEq, Ord, PartialOrd, Hash)] #[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))] pub struct Rectangle

where