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.