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

    pub trait Step: PartialOrd<Self> {
        fn step(&self, by: &Self) -> Option<Self>;
        fn steps_between(start: &Self, end: &Self, by: &Self) -> Option<usize>;
    }

Unstable (`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

### `fn step(&self, by: &Self) -> Option<Self>`

Unstable (`step_trait` #27741)

: likely to be replaced by finer-grained traits

Steps `self` if possible.

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

Unstable (`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.

## 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`

# Help

## Keyboard Shortcuts

?
  Show this help dialog
S
  Focus the search field
⇤
  Move up in search results
⇥
  Move down in search results
⏎
  Go to active search result

## 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`)