CalcAdd

Trait CalcAdd 

Source
pub trait CalcAdd: Sized {
    type Error: Display;

    const ZERO: Self;

    // Required methods
    fn try_add(a: Self, b: Self) -> Result<Self, Self::Error>;
    fn try_sub(a: Self, b: Self) -> Result<Self, Self::Error>;
}
Expand description

A trait for values that support addition and subtraction inside CSS calc() expressions.

Required Associated Constants§

Source

const ZERO: Self

The additive identity (zero) for this type.

Required Associated Types§

Source

type Error: Display

The error type returned if addition or subtraction fails.

Required Methods§

Source

fn try_add(a: Self, b: Self) -> Result<Self, Self::Error>

Attempts to add two values of this type.

Source

fn try_sub(a: Self, b: Self) -> Result<Self, Self::Error>

Attempts to subtract one value from another.

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 CalcAdd for Val

Source§

const ZERO: Self = Val::ZERO

Source§

type Error = String

Source§

fn try_add(a: Self, b: Self) -> Result<Self, Self::Error>

Source§

fn try_sub(a: Self, b: Self) -> Result<Self, Self::Error>

Source§

impl CalcAdd for f32

Source§

const ZERO: Self = 0f32

Source§

type Error = Infallible

Source§

fn try_add(a: Self, b: Self) -> Result<Self, Self::Error>

Source§

fn try_sub(a: Self, b: Self) -> Result<Self, Self::Error>

Source§

impl CalcAdd for Rot2

Source§

const ZERO: Self = Rot2::IDENTITY

Source§

type Error = Infallible

Source§

fn try_add(a: Self, b: Self) -> Result<Self, Self::Error>

Source§

fn try_sub(a: Self, b: Self) -> Result<Self, Self::Error>

Implementors§