Trait TakeRange

Source
pub trait TakeRange<R> {
    type Output;

    // Required method
    fn take_range(&mut self, range: R) -> Self::Output;

    // Provided method
    fn remove_range(&mut self, range: R) { ... }
}
Expand description

Methods for splitting out part of a collection with a given range.

Required Associated Types§

Source

type Output

The value returned by the take_range method, representing the extracted part of the collection.

Required Methods§

Source

fn take_range(&mut self, range: R) -> Self::Output

Splits off and returns part of the collection designated by the given range. The remaining part is left in self with indices adjusted after the removal.

The range parameter typically has one of the standard range types constructed with range expression syntax.

§Panics

The implementation can panic if the range is not valid for the operation.

Provided Methods§

Source

fn remove_range(&mut self, range: R)

Removes items from the the collection as designated by the given range. The remaining part is left in self with indices adjusted after the removal.

The range parameter typically has one of the standard range types constructed with range expression syntax.

The default implementation of this method calls take_range and drops the returned value. Implementors of the trait should consider a more efficient implementation, avoiding construction of an intermediate container.

§Panics

The implementation can panic if the range is not valid for the operation.

Implementations on Foreign Types§

Source§

impl TakeRange<RangeFrom<usize>> for Bytes

Source§

type Output = Bytes

Source§

fn take_range(&mut self, range: RangeFrom<usize>) -> Self::Output

Source§

fn remove_range(&mut self, range: RangeFrom<usize>)

Source§

impl TakeRange<RangeFrom<usize>> for BytesMut

Source§

type Output = BytesMut

Source§

fn take_range(&mut self, range: RangeFrom<usize>) -> Self::Output

Source§

fn remove_range(&mut self, range: RangeFrom<usize>)

Source§

impl TakeRange<RangeFull> for Bytes

Source§

type Output = Bytes

Source§

fn take_range(&mut self, _range: RangeFull) -> Self::Output

Source§

fn remove_range(&mut self, _range: RangeFull)

Source§

impl TakeRange<RangeFull> for BytesMut

Source§

type Output = BytesMut

Source§

fn take_range(&mut self, _range: RangeFull) -> Self::Output

Source§

fn remove_range(&mut self, _range: RangeFull)

Source§

impl TakeRange<RangeTo<usize>> for Bytes

Source§

type Output = Bytes

Source§

fn take_range(&mut self, range: RangeTo<usize>) -> Self::Output

Source§

fn remove_range(&mut self, range: RangeTo<usize>)

Source§

impl TakeRange<RangeTo<usize>> for BytesMut

Source§

type Output = BytesMut

Source§

fn take_range(&mut self, range: RangeTo<usize>) -> Self::Output

Source§

fn remove_range(&mut self, range: RangeTo<usize>)

Source§

impl TakeRange<RangeToInclusive<usize>> for Bytes

Source§

impl TakeRange<RangeToInclusive<usize>> for BytesMut

Implementors§