From 5aa0fd44535faa0ea1c0522b089e16d4b57e4e6f Mon Sep 17 00:00:00 2001 From: Tavian Barnes Date: Sun, 28 Jun 2020 12:34:49 -0400 Subject: Apply some rustfmt suggestions --- src/chebyshev.rs | 2 +- src/coords.rs | 4 ++-- src/cos.rs | 2 +- src/euclid.rs | 6 +++--- src/kd.rs | 12 ++++++------ src/lib.rs | 2 +- src/taxi.rs | 2 +- src/vp.rs | 4 +--- 8 files changed, 16 insertions(+), 18 deletions(-) (limited to 'src') 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 Coordinates for [T] { /// [`Coordinates`] implementation for arrays. macro_rules! array_coordinates { - ($n:expr) => ( + ($n:expr) => { impl Coordinates for [T; $n] { type Value = T; @@ -51,7 +51,7 @@ macro_rules! array_coordinates { self[i] } } - ); + }; } array_coordinates!(1); diff --git a/src/cos.rs b/src/cos.rs index e7f0a87..a3a4f6c 100644 --- a/src/cos.rs +++ b/src/cos.rs @@ -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); diff --git a/src/kd.rs b/src/kd.rs index c29dd80..291028e 100644 --- a/src/kd.rs +++ b/src/kd.rs @@ -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 { impl KdTree { /// 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 FlatKdNode { 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 } diff --git a/src/lib.rs b/src/lib.rs index 346e9e9..8041d28 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -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}; diff --git a/src/vp.rs b/src/vp.rs index 3d88937..85d3972 100644 --- a/src/vp.rs +++ b/src/vp.rs @@ -191,9 +191,7 @@ pub struct VpTree { impl VpTree { /// Create an empty tree. pub fn new() -> Self { - Self { - root: None, - } + Self { root: None } } /// Create a balanced tree out of a sequence of items. -- cgit v1.2.3