From bf2a10ca3b54ac3ed3dcc9c25cb1cf7f07ba8135 Mon Sep 17 00:00:00 2001 From: Tavian Barnes Date: Thu, 21 Oct 2021 14:00:45 -0400 Subject: Add explicit '_ lifetimes to generic types --- src/exhaustive.rs | 2 +- src/kd.rs | 4 ++-- src/lib.rs | 2 ++ src/vp.rs | 16 ++++++++-------- 4 files changed, 13 insertions(+), 11 deletions(-) diff --git a/src/exhaustive.rs b/src/exhaustive.rs index 23a490f..3f42876 100644 --- a/src/exhaustive.rs +++ b/src/exhaustive.rs @@ -16,7 +16,7 @@ impl ExhaustiveSearch { } /// Iterate over the items stored in this index. - pub fn iter(&self) -> Iter { + pub fn iter(&self) -> Iter<'_, T> { self.into_iter() } diff --git a/src/kd.rs b/src/kd.rs index 332cabd..3c3699a 100644 --- a/src/kd.rs +++ b/src/kd.rs @@ -185,7 +185,7 @@ impl KdTree { } /// Iterate over the items stored in this tree. - pub fn iter(&self) -> Iter { + pub fn iter(&self) -> Iter<'_, T> { self.into_iter() } @@ -456,7 +456,7 @@ impl FlatKdTree { } /// Iterate over the items stored in this tree. - pub fn iter(&self) -> FlatIter { + pub fn iter(&self) -> FlatIter<'_, T> { self.into_iter() } } diff --git a/src/lib.rs b/src/lib.rs index 1e77f6b..29d351a 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -122,6 +122,8 @@ //! [`k_nearest_within()`]: knn::NearestNeighbors#method.k_nearest_within //! [`ExactNeighbors`]: knn::ExactNeighbors +#![warn(rust_2018_idioms)] + pub mod chebyshev; pub mod coords; pub mod cos; diff --git a/src/vp.rs b/src/vp.rs index 3e1a8ad..4417b6b 100644 --- a/src/vp.rs +++ b/src/vp.rs @@ -197,7 +197,7 @@ impl VpTree { } /// Iterate over the items stored in this tree. - pub fn iter(&self) -> Iter { + pub fn iter(&self) -> Iter<'_, T> { self.into_iter() } @@ -246,7 +246,7 @@ where T: Proximity + Debug, DistanceValue: Debug, { - fn fmt(&self, f: &mut Formatter) -> fmt::Result { + fn fmt(&self, f: &mut Formatter<'_>) -> fmt::Result { f.debug_struct("VpTree") .field("root", &self.root) .finish() @@ -295,7 +295,7 @@ where T: Proximity + Debug, DistanceValue: Debug, { - fn fmt(&self, f: &mut Formatter) -> fmt::Result { + fn fmt(&self, f: &mut Formatter<'_>) -> fmt::Result { f.debug_struct("IntoIter") .field("stack", &self.stack) .finish() @@ -345,7 +345,7 @@ where T: Proximity + Debug, DistanceValue: Debug, { - fn fmt(&self, f: &mut Formatter) -> fmt::Result { + fn fmt(&self, f: &mut Formatter<'_>) -> fmt::Result { f.debug_struct("Iter") .field("stack", &self.stack) .finish() @@ -504,7 +504,7 @@ impl FlatVpTree { } /// Iterate over the items stored in this tree. - pub fn iter(&self) -> FlatIter { + pub fn iter(&self) -> FlatIter<'_, T> { self.into_iter() } } @@ -514,7 +514,7 @@ where T: Proximity + Debug, DistanceValue: Debug, { - fn fmt(&self, f: &mut Formatter) -> fmt::Result { + fn fmt(&self, f: &mut Formatter<'_>) -> fmt::Result { f.debug_struct("FlatVpTree") .field("nodes", &self.nodes) .finish() @@ -535,7 +535,7 @@ where T: Proximity + Debug, DistanceValue: Debug, { - fn fmt(&self, f: &mut Formatter) -> fmt::Result { + fn fmt(&self, f: &mut Formatter<'_>) -> fmt::Result { f.debug_tuple("FlatIntoIter") .field(&self.0) .finish() @@ -567,7 +567,7 @@ where T: Proximity + Debug, DistanceValue: Debug, { - fn fmt(&self, f: &mut Formatter) -> fmt::Result { + fn fmt(&self, f: &mut Formatter<'_>) -> fmt::Result { f.debug_tuple("FlatIter") .field(&self.0) .finish() -- cgit v1.2.3