Trait taffy::util::math::MaybeMath

source ·
pub trait MaybeMath<In, Out> {
    // Required methods
    fn maybe_min(self, rhs: In) -> Out;
    fn maybe_max(self, rhs: In) -> Out;
    fn maybe_clamp(self, min: In, max: In) -> Out;
    fn maybe_add(self, rhs: In) -> Out;
    fn maybe_sub(self, rhs: In) -> Out;
}
Expand description

A trait to conveniently calculate minimums and maximums when some data may not be defined

If the left-hand value is None, these operations return None. If the right-hand value is None, it is treated as zero.

Required Methods§

source

fn maybe_min(self, rhs: In) -> Out

Returns the minimum of self and rhs

source

fn maybe_max(self, rhs: In) -> Out

Returns the maximum of self and rhs

source

fn maybe_clamp(self, min: In, max: In) -> Out

Returns self clamped between min and max

source

fn maybe_add(self, rhs: In) -> Out

Adds self and rhs.

source

fn maybe_sub(self, rhs: In) -> Out

Subtracts rhs from self, treating None values as default

Implementations on Foreign Types§

source§

impl MaybeMath<Option<f32>, Option<f32>> for Option<f32>

source§

fn maybe_min(self, rhs: Option<f32>) -> Option<f32>

source§

fn maybe_max(self, rhs: Option<f32>) -> Option<f32>

source§

fn maybe_clamp(self, min: Option<f32>, max: Option<f32>) -> Option<f32>

source§

fn maybe_add(self, rhs: Option<f32>) -> Option<f32>

source§

fn maybe_sub(self, rhs: Option<f32>) -> Option<f32>

source§

impl MaybeMath<Option<f32>, f32> for f32

source§

fn maybe_min(self, rhs: Option<f32>) -> f32

source§

fn maybe_max(self, rhs: Option<f32>) -> f32

source§

fn maybe_clamp(self, min: Option<f32>, max: Option<f32>) -> f32

source§

fn maybe_add(self, rhs: Option<f32>) -> f32

source§

fn maybe_sub(self, rhs: Option<f32>) -> f32

source§

impl MaybeMath<f32, Option<f32>> for Option<f32>

source§

fn maybe_min(self, rhs: f32) -> Option<f32>

source§

fn maybe_max(self, rhs: f32) -> Option<f32>

source§

fn maybe_clamp(self, min: f32, max: f32) -> Option<f32>

source§

fn maybe_add(self, rhs: f32) -> Option<f32>

source§

fn maybe_sub(self, rhs: f32) -> Option<f32>

Implementors§