MinDist

Trait MinDist 

Source
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§

Source

fn min_dist_with(&self, other: &T) -> u32

Calculates the minimum distance between the current value and the provided value.

§Arguments
  • other - A reference to the other value to compare against.
§Returns

The minimum distance between the current value and the provided value, as a u32.

Implementations on Foreign Types§

Source§

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

Source§

fn min_dist_with(&self, other: &i32) -> u32

Source§

impl MinDist<Interval<i32>> for i32

Source§

fn min_dist_with(&self, other: &Interval<i32>) -> u32

This Rust function calculates the minimum distance between two intervals of integers.

Arguments:

  • other: The min_dist_with function calculates the minimum distance between two intervals. The self interval is compared with the other interval 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

Implementors§

Source§

impl MinDist<i32> for Interval<i32>

Source§

impl MinDist<Interval<i32>> for Interval<i32>

Source§

impl<T1, T2, U1, U2> MinDist<Point<U1, U2>> for Point<T1, T2>
where T1: MinDist<U1>, T2: MinDist<U2>,