docs

core::range

本页内容

API 参考只有英文版,由标准库源代码中的英文文档注释生成。

Range / RangeInclusive / RangeFrom / RangeTo / RangeToInclusive / RangeFull.

A range expression is a value of these types (let r = 0..5;), built by the #[literal] handlers at the end of this file. for i in a..b with the range written in the loop header keeps a direct counting loop.

Structs

RangeSource

pub struct Range<T>

a..b: from start up to but not including end.

Trait implementations 9

RangeInclusiveSource

pub struct RangeInclusive<T>

a..=b: from start up to and including end.

Trait implementations 4

RangeFromSource

pub struct RangeFrom<T>

a..: from start with no end.

Trait implementations 2

RangeToSource

pub struct RangeTo<T>

..b: up to but not including end.

Trait implementations 1

RangeToInclusiveSource

pub struct RangeToInclusive<T>

..=b: up to and including end.

Trait implementations 1

RangeFullSource

pub struct RangeFull

..: the whole range.

Trait implementations 1

Traits

StepSource

pub trait Step: PartialOrd + Clone

One step forward / back. Integers implement it; floats don't, so Range<f64> is no iterator.

  • fn forward_checked(self, count: usize) -> Self | none§

    Source

    self moved count steps forward, or none past the type's end.

  • fn backward_checked(self, count: usize) -> Self | none§

    Source

    self moved count steps back, or none past the type's start.

  • fn steps_between(start: Self, end: Self) -> usize | none§

    Source

    The steps from start to end, or none when end is before start or the count overflows usize.