rokdocs
v0.1

rok::core::range

Range / RangeInclusive / RangeFrom / RangeTo / RangeToInclusive / RangeFull (stdlib 2.7.4, refs-lang 3.7).

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

Range

pub struct Range<T>
  • pub start: T
  • pub end: T
Trait implementations 7
  • impl<T: Clone> Clone for Range<T>
  • impl<T: Copy> Copy for Range<T>
  • impl<T: PartialEq> PartialEq for Range<T>
  • impl<T: Eq> Eq for Range<T>
  • impl<T: Step> Iterator for Range<T>
  • impl<T: Step> DoubleEndedIterator for Range<T>
  • impl<T: Step> ExactSizeIterator for Range<T>

RangeInclusive

pub struct RangeInclusive<T>
  • pub start: T
  • pub end: T
Trait implementations 3
  • impl<T: Step> Iterator for RangeInclusive<T>
  • impl<T: Step> DoubleEndedIterator for RangeInclusive<T>
  • impl<T: Step> ExactSizeIterator for RangeInclusive<T>

RangeFrom

pub struct RangeFrom<T>
  • pub start: T
Trait implementations 1
  • impl<T: Step> Iterator for RangeFrom<T>

RangeTo

pub struct RangeTo<T>
  • pub end: T

RangeToInclusive

pub struct RangeToInclusive<T>

..=b: up to and including end (the spec's range grammar has no ..=b form; this mirrors RangeTo).

  • pub end: T

RangeFull

pub struct RangeFull

Traits

Step

pub trait Step: PartialOrd + Clone

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

  • fn forward_checked(self, count: usize) -> Self | none
  • fn backward_checked(self, count: usize) -> Self | none
  • fn steps_between(start: Self, end: Self) -> usize | none

Functions

range_literal

pub const fn range_literal<T>(start: T, end: T) -> Range<T>

range_inclusive_literal

pub const fn range_inclusive_literal<T>(start: T, end: T) -> RangeInclusive<T>

range_from_literal

pub const fn range_from_literal<T>(start: T) -> RangeFrom<T>

range_to_literal

pub const fn range_to_literal<T>(end: T) -> RangeTo<T>

range_to_inclusive_literal

pub const fn range_to_inclusive_literal<T>(end: T) -> RangeToInclusive<T>

range_full_literal

pub const fn range_full_literal() -> RangeFull