Skip to main content

Increment

Trait Increment 

Source
pub trait Increment:
    Sized
    + One
    + Add<Output = Self>
    + AddAssign
    + Copy {
    // Provided methods
    fn increment(&mut self) { ... }
    fn increment_checked(&mut self) -> Result<(), ()>
       where Self: OverflowBehavior + MaxValue + PartialEq { ... }
    fn can_increment(&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 increment(&mut self)

The increment x++ operator

Source

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

The increment x++ operator

Source

fn can_increment(&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".

Implementors§

Source§

impl<T> Increment for T
where T: One + Add<Output = T> + AddAssign + Copy,