std::iter::Step - Rust
Description: API documentation for the Rust `Step` trait in crate `std`.
Keywords: rust, rustlang, rust-lang, Step

# Trait std::iter::Step[−][src]

    pub trait Step: PartialOrd<Self> + Clone {
        fn steps_between(start: &Self, end: &Self) -> Option<usize>;
        fn replace_one(&mut self) -> Self;
        fn replace_zero(&mut self) -> Self;
        fn add_one(&self) -> Self;
        fn sub_one(&self) -> Self;
        fn add_usize(&self, n: usize) -> Option<Self>;
    }

🔬 This is a nightly-only experimental API. (`step_trait` #42168)

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

### `fn steps_between(start: &Self, end: &Self) -> Option<usize>`

🔬 This is a nightly-only experimental API. (`step_trait` #42168)

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.

### `fn replace_one(&mut self) -> Self`

🔬 This is a nightly-only experimental API. (`step_trait` #42168)

likely to be replaced by finer-grained traits

Replaces this step with `1`, returning itself

### `fn replace_zero(&mut self) -> Self`

🔬 This is a nightly-only experimental API. (`step_trait` #42168)

likely to be replaced by finer-grained traits

Replaces this step with `0`, returning itself

### `fn add_one(&self) -> Self`

🔬 This is a nightly-only experimental API. (`step_trait` #42168)

likely to be replaced by finer-grained traits

Adds one to this step, returning the result

### `fn sub_one(&self) -> Self`

🔬 This is a nightly-only experimental API. (`step_trait` #42168)

likely to be replaced by finer-grained traits

Subtracts one to this step, returning the result

### `fn add_usize(&self, n: usize) -> Option<Self>`

🔬 This is a nightly-only experimental API. (`step_trait` #42168)

likely to be replaced by finer-grained traits

Add an usize, returning None on overflow

## Implementors

- `impl Step for u32` | [src]

- `impl Step for isize` | [src]

- `impl Step for u64` | [src]

- `impl Step for i128` | [src]

- `impl Step for u16` | [src]

- `impl Step for i16` | [src]

- `impl Step for u8` | [src]

- `impl Step for usize` | [src]

- `impl Step for u128` | [src]

- `impl Step for i8` | [src]

- `impl Step for i32` | [src]

- `impl Step for i64` | [src]

# Help

## Keyboard Shortcuts

`?`
  Show this help dialog
`S`
  Focus the search field
`↑`
  Move up in search results
`↓`
  Move down in search results
`↹`
  Switch tab
`⏎`
  Go to active search result
`+`
  Expand all sections
`-`
  Collapse all sections

## Search Tricks

Prefix searches with a type followed by a colon (e.g. `fn:`) to restrict the search to a given type.

Accepted types are: `fn`, `mod`, `struct`, `enum`, `trait`, `type`, `macro`, and `const`.

Search functions by type signature (e.g. `vec -> usize` or `* -> vec`)

Search multiple things at once by splitting your query with comma (e.g. `str,u8` or `String,struct:Vec,test`)