Skip to main content

Increase

Trait Increase 

Source
pub trait Increase:
    Sized
    + One
    + Add<Output = Self>
    + AddAssign
    + Copy {
    // Provided methods
    fn increase(&mut self) { ... }
    fn increase_checked(&mut self) -> Result<(), ()>
       where Self: OverflowBehavior + MaxValue + PartialEq { ... }
    fn can_increase(&self) -> bool
       where Self: OverflowBehavior + MaxValue + PartialEq { ... }
    fn successor(self) -> Self { ... }
    fn successor_checked(&mut self) -> Result<Self, ()>
       where Self: OverflowBehavior + MaxValue + PartialEq { ... }
    fn have_successor(self) -> bool
       where Self: OverflowBehavior + MaxValue + PartialEq { ... }
}
Expand description

The +1 operation

Provided Methods§

Source

fn increase(&mut self)

The increment x++ operator

Source

fn increase_checked(&mut self) -> Result<(), ()>

The increment x++ operator

Source

fn can_increase(&self) -> bool

Do the current value have a successor.

True if not Self::MAX, except for wrapping type, they always have a successor because they wrap

Source

fn successor(self) -> Self

Return the successor self + 1

Source

fn successor_checked(&mut self) -> Result<Self, ()>

Return the successor self + 1

Source

fn have_successor(self) -> bool

Do the current value have a successor.

True if not Self::MAX, except for wrapping type, they always have a successor because they wrap

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<T> Increase for T
where T: One + Add<Output = T> + AddAssign + Copy,