Trait MinMax

Source
pub trait MinMax {
    // Required methods
    fn infimum(&self, other: &Self) -> Self;
    fn supremum(&self, other: &Self) -> Self;
}
Expand description

Helper trait for computing minimum and maximum values for types. This is used in conjunction with PrimitiveType to enable min/max computations even for vector types

Required Methods§

Source

fn infimum(&self, other: &Self) -> Self

Computes the infimum of this value and other. For scalar types, the infimum is simply the minimum of the two types (as defined by PartialOrd), for vector types, this is the component-wise minimum

§Example
use pasture_core::math::MinMax;

assert_eq!(5i32.infimum(&3i32), 3i32);
assert_eq!(Vector3::new(1.0, 2.0, 3.0).infimum(&Vector3::new(2.0, 1.0, 0.0)), Vector3::new(1.0, 1.0, 0.0));
Source

fn supremum(&self, other: &Self) -> Self

Computes the supremum of this value and other. For scalar types, the infimum is simply the maximum of the two types (as defined by PartialOrd), for vector types, this is the component-wise maximum

§Example
use pasture_core::math::MinMax;

assert_eq!(5i32.supremum(&3i32), 5i32);
assert_eq!(Vector3::new(1.0, 2.0, 3.0).supremum(&Vector3::new(2.0, 1.0, 4.0)), Vector3::new(2.0, 2.0, 4.0));

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.

Implementations on Foreign Types§

Source§

impl MinMax for bool

Source§

fn infimum(&self, other: &Self) -> Self

Source§

fn supremum(&self, other: &Self) -> Self

Source§

impl MinMax for f32

Source§

fn infimum(&self, other: &Self) -> Self

Source§

fn supremum(&self, other: &Self) -> Self

Source§

impl MinMax for f64

Source§

fn infimum(&self, other: &Self) -> Self

Source§

fn supremum(&self, other: &Self) -> Self

Source§

impl MinMax for i8

Source§

fn infimum(&self, other: &Self) -> Self

Source§

fn supremum(&self, other: &Self) -> Self

Source§

impl MinMax for i16

Source§

fn infimum(&self, other: &Self) -> Self

Source§

fn supremum(&self, other: &Self) -> Self

Source§

impl MinMax for i32

Source§

fn infimum(&self, other: &Self) -> Self

Source§

fn supremum(&self, other: &Self) -> Self

Source§

impl MinMax for i64

Source§

fn infimum(&self, other: &Self) -> Self

Source§

fn supremum(&self, other: &Self) -> Self

Source§

impl MinMax for u8

Source§

fn infimum(&self, other: &Self) -> Self

Source§

fn supremum(&self, other: &Self) -> Self

Source§

impl MinMax for u16

Source§

fn infimum(&self, other: &Self) -> Self

Source§

fn supremum(&self, other: &Self) -> Self

Source§

impl MinMax for u32

Source§

fn infimum(&self, other: &Self) -> Self

Source§

fn supremum(&self, other: &Self) -> Self

Source§

impl MinMax for u64

Source§

fn infimum(&self, other: &Self) -> Self

Source§

fn supremum(&self, other: &Self) -> Self

Source§

impl<T: MinMax + Scalar> MinMax for Vector3<T>

Source§

fn infimum(&self, other: &Self) -> Self

Source§

fn supremum(&self, other: &Self) -> Self

Implementors§