Trait lay_rs::prelude::taffy::MaybeMath

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§

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

Returns the minimum of self and rhs

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

Returns the maximum of self and rhs

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

Returns self clamped between min and max

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

Adds self and rhs.

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

Subtracts rhs from self, treating None values as default

Implementations on Foreign Types§

§

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

§

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

§

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

§

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

§

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

§

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

§

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

§

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

§

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

§

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

§

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

§

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

§

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

§

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

§

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

§

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

§

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

§

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

Implementors§

§

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

§

impl MaybeMath<f32, AvailableSpace> for AvailableSpace

§

impl<In, Out, T> MaybeMath<Size<In>, Size<Out>> for Size<T>
where T: MaybeMath<In, Out>,