W3cubDocs

/Rust

Trait std::iter::Step

pub trait Step: PartialOrd<Self> {
    fn step(&self, by: &Self) -> Option<Self>;
    fn steps_between(start: &Self, end: &Self, by: &Self) -> Option<usize>;
    fn steps_between_by_one(start: &Self, end: &Self) -> Option<usize>;
    fn is_negative(&self) -> bool;
    fn replace_one(&mut self) -> Self;
    fn replace_zero(&mut self) -> Self;
    fn add_one(&self) -> Self;
    fn sub_one(&self) -> Self;
}
🔬 This is a nightly-only experimental API. (step_trait #27741)likely to be replaced by finer-grained traits

Objects that can be stepped over in both directions.

The steps_between function provides a way to efficiently compare two Step objects.

Required Methods

🔬 This is a nightly-only experimental API. (step_trait #27741)likely to be replaced by finer-grained traits

Steps self if possible.

🔬 This is a nightly-only experimental API. (step_trait #27741)likely to be replaced by finer-grained traits

Returns the number of steps between two step objects. The count is inclusive of start and exclusive of end.

Returns None if it is not possible to calculate steps_between without overflow.

🔬 This is a nightly-only experimental API. (step_trait #27741)likely to be replaced by finer-grained traits

Same as steps_between, but with a by of 1

🔬 This is a nightly-only experimental API. (step_trait #27741)likely to be replaced by finer-grained traits

Tests whether this step is negative or not (going backwards)

🔬 This is a nightly-only experimental API. (step_trait #27741)likely to be replaced by finer-grained traits

Replaces this step with 1, returning itself

🔬 This is a nightly-only experimental API. (step_trait #27741)likely to be replaced by finer-grained traits

Replaces this step with 0, returning itself

🔬 This is a nightly-only experimental API. (step_trait #27741)likely to be replaced by finer-grained traits

Adds one to this step, returning the result

🔬 This is a nightly-only experimental API. (step_trait #27741)likely to be replaced by finer-grained traits

Subtracts one to this step, returning the result

Implementors

  • impl Step for usize
  • impl Step for u8
  • impl Step for u16
  • impl Step for u32
  • impl Step for isize
  • impl Step for i8
  • impl Step for i16
  • impl Step for i32
  • impl Step for u64
  • impl Step for i64
  • impl Step for u128
  • impl Step for i128

© 2010 The Rust Project Developers
Licensed under the Apache License, Version 2.0 or the MIT license, at your option.
https://doc.rust-lang.org/std/iter/trait.Step.html