summaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorTavian Barnes <tavianator@tavianator.com>2020-06-28 12:34:49 -0400
committerTavian Barnes <tavianator@tavianator.com>2020-06-28 12:34:49 -0400
commit5aa0fd44535faa0ea1c0522b089e16d4b57e4e6f (patch)
tree1dcc37412195f0851dd86b836368bf809a35b4b4 /src
parent7ce5a60f5fc69f9c47cdae2762b14873d3e90733 (diff)
downloadacap-5aa0fd44535faa0ea1c0522b089e16d4b57e4e6f.tar.xz
Apply some rustfmt suggestions
Diffstat (limited to 'src')
-rw-r--r--src/chebyshev.rs2
-rw-r--r--src/coords.rs4
-rw-r--r--src/cos.rs2
-rw-r--r--src/euclid.rs6
-rw-r--r--src/kd.rs12
-rw-r--r--src/lib.rs2
-rw-r--r--src/taxi.rs2
-rw-r--r--src/vp.rs4
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);
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<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
}
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<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.