Skip to main content

MinDist

Trait MinDist 

Source
pub trait MinDist<T> {
    // Required method
    fn min_dist_with(&self, other: &T) -> u32;
}
Expand description

Trait for calculating the minimum distance between two values.

§Examples

use physdes::generic::MinDist;

let a: i32 = 10;
let b: i32 = 5;
let distance = a.min_dist_with(&b);
assert_eq!(distance, 5);

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.

Dyn Compatibility§

This trait is dyn compatible.

In older versions of Rust, dyn compatibility was called "object safety".

Implementations on Foreign Types§

Source§

impl MinDist<Interval<i32>> for i32

Source§

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

Computes the minimum distance between a scalar and an interval.

Source§

impl MinDist<i32> for i32

Computes the absolute difference between two i32 values.

$$d = |a - b|$$

§Examples

use physdes::generic::MinDist;

let a: i32 = 10;
let b: i32 = 5;
let distance = a.min_dist_with(&b);
assert_eq!(distance, 5);
Source§

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

Minimum distance between two scalars is the absolute difference:

$$d = |a - b|$$

Implementors§

Source§

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

Source§

impl MinDist<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>,