pub trait DistanceIterator: Iterator + Sized{
// Provided methods
fn closer<T: Into<Point2>>(self, distance: f32, target: T) -> Closer<Self> ⓘ { ... }
fn further<T: Into<Point2>>(self, distance: f32, target: T) -> Further<Self> ⓘ { ... }
fn closest<T: Into<Point2>>(self, target: T) -> Option<Self::Item> { ... }
fn furthest<T: Into<Point2>>(self, target: T) -> Option<Self::Item> { ... }
fn closest_distance<T: Into<Point2>>(self, target: T) -> Option<f32> { ... }
fn furthest_distance<T: Into<Point2>>(self, target: T) -> Option<f32> { ... }
fn closest_distance_squared<T: Into<Point2>>(self, target: T) -> Option<f32> { ... }
fn furthest_distance_squared<T: Into<Point2>>(
self,
target: T,
) -> Option<f32> { ... }
fn sort_by_distance<T: Into<Point2>>(
self,
target: T,
) -> IntoIter<Self::Item> { ... }
fn sort_unstable_by_distance<T: Into<Point2>>(
self,
target: T,
) -> IntoIter<Self::Item> { ... }
}
Expand description
Helper trait for iterators of items implementing Distance
.
Provided Methods§
Sourcefn closer<T: Into<Point2>>(self, distance: f32, target: T) -> Closer<Self> ⓘ
fn closer<T: Into<Point2>>(self, distance: f32, target: T) -> Closer<Self> ⓘ
Filters all items closer than given distance
to target
.
Sourcefn further<T: Into<Point2>>(self, distance: f32, target: T) -> Further<Self> ⓘ
fn further<T: Into<Point2>>(self, distance: f32, target: T) -> Further<Self> ⓘ
Filters all items further than given distance
to target
.
Sourcefn closest<T: Into<Point2>>(self, target: T) -> Option<Self::Item>
fn closest<T: Into<Point2>>(self, target: T) -> Option<Self::Item>
Returns closest to target
item in iterator.
Sourcefn furthest<T: Into<Point2>>(self, target: T) -> Option<Self::Item>
fn furthest<T: Into<Point2>>(self, target: T) -> Option<Self::Item>
Returns furthest to target
item in iterator.
Sourcefn closest_distance<T: Into<Point2>>(self, target: T) -> Option<f32>
fn closest_distance<T: Into<Point2>>(self, target: T) -> Option<f32>
Returns distance to closest to target
item in iterator.
Sourcefn furthest_distance<T: Into<Point2>>(self, target: T) -> Option<f32>
fn furthest_distance<T: Into<Point2>>(self, target: T) -> Option<f32>
Returns distance to furthest to target
item in iterator.
Sourcefn closest_distance_squared<T: Into<Point2>>(self, target: T) -> Option<f32>
fn closest_distance_squared<T: Into<Point2>>(self, target: T) -> Option<f32>
Returns squared distance to closest to target
item in iterator.
Sourcefn furthest_distance_squared<T: Into<Point2>>(self, target: T) -> Option<f32>
fn furthest_distance_squared<T: Into<Point2>>(self, target: T) -> Option<f32>
Returns squared distance to furthest to target
item in iterator.
Sourcefn sort_by_distance<T: Into<Point2>>(self, target: T) -> IntoIter<Self::Item>
fn sort_by_distance<T: Into<Point2>>(self, target: T) -> IntoIter<Self::Item>
Returns iterator of items sorted by distance to target
.
This sort is stable (i.e., does not reorder equal elements) and O(n * log(n))
worst-case.
When applicable, unstable sorting is preferred because it is generally faster than stable sorting
and it doesn’t allocate auxiliary memory. See sort_unstable_by_distance
.
Dyn Compatibility§
This trait is not dyn compatible.
In older versions of Rust, dyn compatibility was called "object safety", so this trait is not object safe.