Trait rangemap::StepLite

source ·
pub trait StepLite {
    // Required methods
    fn add_one(&self) -> Self;
    fn sub_one(&self) -> Self;
}
Expand description

Minimal version of unstable Step trait from the Rust standard library.

This is needed for RangeInclusiveMap because ranges stored as its keys interact with each other when the start of one is adjacent the end of another. I.e. we need a concept of successor values rather than just equality, and that is what Step will eventually provide once it is stabilized.

NOTE: This will likely be deprecated and then eventually removed once the standard library’s Step trait is stabilised, as most crates will then likely implement Step for their types where appropriate.

See this issue for details about that stabilization process.

Required Methods§

source

fn add_one(&self) -> Self

Returns the successor of self.

If this would overflow the range of values supported by Self, this function is allowed to panic, wrap, or saturate. The suggested behavior is to panic when debug assertions are enabled, and to wrap or saturate otherwise.

source

fn sub_one(&self) -> Self

Returns the predecessor of self.

If this would overflow the range of values supported by Self, this function is allowed to panic, wrap, or saturate. The suggested behavior is to panic when debug assertions are enabled, and to wrap or saturate otherwise.

Object Safety§

This trait is not object safe.

Implementations on Foreign Types§

source§

impl StepLite for i8

source§

fn add_one(&self) -> Self

source§

fn sub_one(&self) -> Self

source§

impl StepLite for i16

source§

fn add_one(&self) -> Self

source§

fn sub_one(&self) -> Self

source§

impl StepLite for i32

source§

fn add_one(&self) -> Self

source§

fn sub_one(&self) -> Self

source§

impl StepLite for i64

source§

fn add_one(&self) -> Self

source§

fn sub_one(&self) -> Self

source§

impl StepLite for i128

source§

fn add_one(&self) -> Self

source§

fn sub_one(&self) -> Self

source§

impl StepLite for u8

source§

fn add_one(&self) -> Self

source§

fn sub_one(&self) -> Self

source§

impl StepLite for u16

source§

fn add_one(&self) -> Self

source§

fn sub_one(&self) -> Self

source§

impl StepLite for u32

source§

fn add_one(&self) -> Self

source§

fn sub_one(&self) -> Self

source§

impl StepLite for u64

source§

fn add_one(&self) -> Self

source§

fn sub_one(&self) -> Self

source§

impl StepLite for u128

source§

fn add_one(&self) -> Self

source§

fn sub_one(&self) -> Self

source§

impl StepLite for usize

source§

fn add_one(&self) -> Self

source§

fn sub_one(&self) -> Self

Implementors§