[][src]Struct range::Range

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: usize

The range offset

length: usize

The range length

data: T

The data described within the range.

Methods

impl Range[src]

pub fn new(offset: usize, length: usize) -> Range[src]

Creates a new Range

pub fn wrap<T>(self, data: T) -> Range<T>[src]

Wraps some data in the range.

pub fn empty(offset: usize) -> Range[src]

Creates an empty range with an offset.

pub fn shrink_n(&self, n: usize) -> Option<Range>[src]

Shrinks range at both ends with n items.

pub fn shrink(&self) -> Option<Range>[src]

Shrinks range at both ends with 1 item.

pub fn intersect(&self, other: &Range) -> Option<Range>[src]

Intersects a range with another, where ends are excluded.

pub fn ends_intersect(&self, other: &Range) -> Option<Range>[src]

Intersects a range with another, where ends are included.

impl<T> Range<T>[src]

pub fn is_empty(&self) -> bool[src]

Returns true if range is empty

pub fn next_offset(&self) -> usize[src]

Returns the next offset

pub fn iter(&self) -> Range<usize>[src]

Returns a range iterator.

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

Maps from some data to another.

pub fn range(&self) -> Range[src]

Returns range information without the data.

pub fn unwrap(self) -> T[src]

Unwraps the data.

pub fn decouple(self) -> (Range, T)[src]

Decouples range and data.

Trait Implementations

impl<T: Copy> Copy for Range<T>[src]

impl<T: Eq> Eq for Range<T>[src]

impl<T: Clone> Clone for Range<T>[src]

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

Performs copy-assignment from source. Read more

impl<T: PartialEq> PartialEq<Range<T>> for Range<T>[src]

impl<T> From<(Range<()>, T)> for Range<T>[src]

impl<T: Debug> Debug for Range<T>[src]

impl<T: Hash> Hash for Range<T>[src]

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

Feeds a slice of this type into the given [Hasher]. Read more

Auto Trait Implementations

impl<T> Send for Range<T> where
    T: Send

impl<T> Sync for Range<T> where
    T: Sync

Blanket Implementations

impl<T, U> Into<U> for T where
    U: From<T>, 
[src]

impl<T> From<T> for T[src]

impl<T> ToOwned for T where
    T: Clone
[src]

type Owned = T

The resulting type after obtaining ownership.

impl<T, U> TryFrom<U> for T where
    U: Into<T>, 
[src]

type Error = Infallible

The type returned in the event of a conversion error.

impl<T, U> TryInto<U> for T where
    U: TryFrom<T>, 
[src]

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.

impl<T> Borrow<T> for T where
    T: ?Sized
[src]

impl<T> BorrowMut<T> for T where
    T: ?Sized
[src]

impl<T> Any for T where
    T: 'static + ?Sized
[src]