Struct range::Range [] [src]

pub struct Range<T = ()> {
    pub offset: usize,
    pub length: usize,
    pub data: T,
}

A representation of a range

The type parameter is used to wrap data related to the range.

Fields

offset

The range offset

length

The range length

data

The data described within the range.

Methods

impl Range

fn new(offset: usize, length: usize) -> Range

Creates a new Range

fn wrap<T>(self, data: T) -> Range<T>

Wraps some data in the range.

fn empty(offset: usize) -> Range

Creates an empty range with an offset.

fn shrink_n(&self, n: usize) -> Option<Range>

Shrinks range at both ends with n items.

fn shrink(&self) -> Option<Range>

Shrinks range at both ends with 1 item.

fn intersect(&self, other: &Range) -> Option<Range>

Intersects a range with another, where ends are excluded.

fn ends_intersect(&self, other: &Range) -> Option<Range>

Intersects a range with another, where ends are included.

impl<T> Range<T>

fn is_empty(&self) -> bool

Returns true if range is empty

fn next_offset(&self) -> usize

Returns the next offset

fn iter(&self) -> Range<usize>

Returns a range iterator.

fn map<U, F: FnOnce(T) -> U>(self, f: F) -> Range<U>

Maps from some data to another.

fn range(&self) -> Range

Returns range information without the data.

fn unwrap(self) -> T

Unwraps the data.

fn decouple(self) -> (Range, T)

Decouples range and data.

Trait Implementations

impl<T> From<(Range, T)> for Range<T>

fn from((r, d): (Range, T)) -> Range<T>

Derived Implementations

impl<T: Debug> Debug for Range<T>

fn fmt(&self, __arg_0: &mut Formatter) -> Result

impl<T: Hash> Hash for Range<T>

fn hash<__H: Hasher>(&self, __arg_0: &mut __H)

1.3.0fn hash_slice<H>(data: &[Self], state: &mut H) where H: Hasher

impl<T: Eq> Eq for Range<T>

impl<T: PartialEq> PartialEq for Range<T>

fn eq(&self, __arg_0: &Range<T>) -> bool

fn ne(&self, __arg_0: &Range<T>) -> bool

impl<T: Clone> Clone for Range<T>

fn clone(&self) -> Range<T>

1.0.0fn clone_from(&mut self, source: &Self)

impl<T: Copy> Copy for Range<T>