Skip to main content

Decrement

Trait Decrement 

Source
pub trait Decrement:
    Sized
    + One
    + Sub<Output = Self>
    + SubAssign
    + Copy {
    // Provided methods
    fn decrement(&mut self) { ... }
    fn decrement_checked(&mut self) -> Result<(), ()>
       where Self: OverflowBehavior + MinValue + PartialEq { ... }
    fn can_decrement(&self) -> bool
       where Self: OverflowBehavior + MinValue + PartialEq { ... }
    fn predecessor(self) -> Self { ... }
    fn predecessor_checked(&mut self) -> Result<Self, ()>
       where Self: OverflowBehavior + MinValue + PartialEq { ... }
    fn have_predecessor(self) -> bool
       where Self: OverflowBehavior + MinValue + PartialEq { ... }
}
Expand description

The -1 operation

Provided Methods§

Source

fn decrement(&mut self)

The decrement x-- operator

Source

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

The increment x-- operator

Source

fn can_decrement(&self) -> bool

Do the current value have a predecessor.

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

Source

fn predecessor(self) -> Self

Return the predecessor self - 1

Source

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

Return the predecessor self - 1

Source

fn have_predecessor(self) -> bool

Do the current value have a predecessor.

True if not Self::MIN, except for wrapping type, they always have a predecessor 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> Decrement for T
where T: One + Sub<Output = T> + SubAssign + Copy,