pub trait MinDist<T> {
// Required method
fn min_dist_with(&self, other: &T) -> u32;
}Expand description
Defines a trait for calculating the minimum distance between two values of type T.
This trait provides a single method, min_dist_with, which takes a reference to another value of type T
and returns the minimum distance between the two values as a u32.
Required Methods§
Implementations on Foreign Types§
Source§impl MinDist<i32> for i32
Computes the absolute difference between two i32 values.
impl MinDist<i32> for i32
Computes the absolute difference between two i32 values.
This implementation of the MinDist trait for i32 calculates the unsigned
absolute difference between the current i32 value and the provided other
i32 value.
§Examples
use your_crate::MinDist;
let a: i32 = 10; let b: i32 = 5; let distance = a.min_dist_with(&b); // distance = 5
fn min_dist_with(&self, other: &i32) -> u32
Source§impl MinDist<Interval<i32>> for i32
impl MinDist<Interval<i32>> for i32
Source§fn min_dist_with(&self, other: &Interval<i32>) -> u32
fn min_dist_with(&self, other: &Interval<i32>) -> u32
This Rust function calculates the minimum distance between two intervals of integers.
Arguments:
other: Themin_dist_withfunction calculates the minimum distance between two intervals. Theselfinterval is compared with theotherinterval to determine the minimum distance between them.
Returns:
The min_dist_with function returns the minimum distance between two intervals. If the lower
bound of self is less than the lower bound of other, it returns the difference between the
lower bounds as a u32. If the upper bound of other is less than the upper bound of self,
it returns the difference between the upper bounds as a u32. Otherwise