Trait TrySub

Source
pub trait TrySub: Sized {
    // Required method
    fn try_sub(&self, other: &Self) -> Result<Self, Error>;
}
Expand description

A trait for types that support fallible subtraction

This trait is similar to the standard Sub trait, but returns a Result to handle cases where subtraction might fail.

§Type Parameters

  • Sized - Required to ensure the type can be used by value

Required Methods§

Source

fn try_sub(&self, other: &Self) -> Result<Self, Error>

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.

Implementors§

Source§

impl TrySub for Value

Source§

impl<T: Sub<Output = T> + Copy> TrySub for T