diff options
Diffstat (limited to 'src')
-rw-r--r-- | src/chebyshev.rs | 2 | ||||
-rw-r--r-- | src/coords.rs | 4 | ||||
-rw-r--r-- | src/cos.rs | 2 | ||||
-rw-r--r-- | src/euclid.rs | 6 | ||||
-rw-r--r-- | src/kd.rs | 12 | ||||
-rw-r--r-- | src/lib.rs | 2 | ||||
-rw-r--r-- | src/taxi.rs | 2 | ||||
-rw-r--r-- | src/vp.rs | 4 |
8 files changed, 16 insertions, 18 deletions
diff --git a/src/chebyshev.rs b/src/chebyshev.rs index bddbd5e..f6eba8a 100644 --- a/src/chebyshev.rs +++ b/src/chebyshev.rs @@ -1,6 +1,6 @@ //! [Chebyshev distance](https://en.wikipedia.org/wiki/Chebyshev_distance). -use crate::coords::{Coordinates, CoordinateMetric, CoordinateProximity}; +use crate::coords::{CoordinateMetric, CoordinateProximity, Coordinates}; use crate::distance::{Metric, Proximity}; use num_traits::{zero, Signed}; diff --git a/src/coords.rs b/src/coords.rs index a95e378..2e292ae 100644 --- a/src/coords.rs +++ b/src/coords.rs @@ -39,7 +39,7 @@ impl<T: Value> Coordinates for [T] { /// [`Coordinates`] implementation for arrays. macro_rules! array_coordinates { - ($n:expr) => ( + ($n:expr) => { impl<T: Value> Coordinates for [T; $n] { type Value = T; @@ -51,7 +51,7 @@ macro_rules! array_coordinates { self[i] } } - ); + }; } array_coordinates!(1); @@ -484,7 +484,7 @@ macro_rules! impl_distance { impl Distance for AngularDistance<$f> { type Value = $f; } - } + }; } impl_distance!(f32); diff --git a/src/euclid.rs b/src/euclid.rs index c1d88ae..3833146 100644 --- a/src/euclid.rs +++ b/src/euclid.rs @@ -1,6 +1,6 @@ //! [Euclidean space](https://en.wikipedia.org/wiki/Euclidean_space). -use crate::coords::{Coordinates, CoordinateMetric, CoordinateProximity}; +use crate::coords::{CoordinateMetric, CoordinateProximity, Coordinates}; use crate::distance::{Distance, Metric, Proximity, Value}; use num_traits::zero; @@ -243,7 +243,7 @@ macro_rules! float_distance { impl Distance for EuclideanDistance<$f> { type Value = $f; } - } + }; } float_distance!(f32); @@ -353,7 +353,7 @@ macro_rules! int_distance { impl Distance for EuclideanDistance<$i> { type Value = $f; } - } + }; } int_distance!(i16, f32, f32); @@ -1,6 +1,6 @@ //! [k-d trees](https://en.wikipedia.org/wiki/K-d_tree). -use crate::coords::{Coordinates, CoordinateMetric, CoordinateProximity}; +use crate::coords::{CoordinateMetric, CoordinateProximity, Coordinates}; use crate::distance::{Metric, Proximity}; use crate::util::Ordered; use crate::{ExactNeighbors, NearestNeighbors, Neighborhood}; @@ -200,9 +200,7 @@ pub struct KdTree<T> { impl<T: Coordinates> KdTree<T> { /// Create an empty tree. pub fn new() -> Self { - Self { - root: None, - } + Self { root: None } } /// Create a balanced tree out of a sequence of items. @@ -378,7 +376,7 @@ impl<T: Coordinates> FlatKdNode<T> { nodes.swap(0, mid); let (node, children) = nodes.split_first_mut().unwrap(); - let (left, right) = children.split_at_mut(mid); + let (left, right) = children.split_at_mut(mid); node.left_len = left.len(); let next = (level + 1) % node.item.dims(); @@ -477,7 +475,9 @@ where { if !self.nodes.is_empty() { let mut closest = neighborhood.target().as_vec(); - self.nodes.as_slice().search(0, &mut closest, &mut neighborhood); + self.nodes + .as_slice() + .search(0, &mut closest, &mut neighborhood); } neighborhood } @@ -111,8 +111,8 @@ pub use distance::{Distance, Metric, Proximity}; pub use euclid::{euclidean_distance, Euclidean, EuclideanDistance}; use std::cmp::Ordering; -use std::convert::TryInto; use std::collections::BinaryHeap; +use std::convert::TryInto; /// A nearest neighbor. #[derive(Clone, Copy, Debug)] diff --git a/src/taxi.rs b/src/taxi.rs index 8bbe2f3..7c33ecb 100644 --- a/src/taxi.rs +++ b/src/taxi.rs @@ -1,6 +1,6 @@ //! [Taxicab (Manhattan) distance](https://en.wikipedia.org/wiki/Taxicab_geometry). -use crate::coords::{Coordinates, CoordinateMetric, CoordinateProximity}; +use crate::coords::{CoordinateMetric, CoordinateProximity, Coordinates}; use crate::distance::{Metric, Proximity}; use num_traits::{zero, Signed}; @@ -191,9 +191,7 @@ pub struct VpTree<T: Proximity> { impl<T: Proximity> VpTree<T> { /// Create an empty tree. pub fn new() -> Self { - Self { - root: None, - } + Self { root: None } } /// Create a balanced tree out of a sequence of items. |