[][src]Trait bitvec::slice::BitSliceIndex

pub trait BitSliceIndex<'a, O, T> where
    O: 'a + BitOrder,
    T: 'a + BitStore
{ type Immut; type Mut; fn get(self, slice: &'a BitSlice<O, T>) -> Option<Self::Immut>;
fn get_mut(self, slice: &'a mut BitSlice<O, T>) -> Option<Self::Mut>;
unsafe fn get_unchecked(self, slice: &'a BitSlice<O, T>) -> Self::Immut;
unsafe fn get_unchecked_mut(
        self,
        slice: &'a mut BitSlice<O, T>
    ) -> Self::Mut;
fn index(self, slice: &'a BitSlice<O, T>) -> Self::Immut;
fn index_mut(self, slice: &'a mut BitSlice<O, T>) -> Self::Mut; }

Replacement for slice::SliceIndex.

This trait is stabilized in definition and type Output only, but all methods are unstable. This makes it unusable in non-libstd slice libraries, and so it must be duplicated here.

There is no tracking issue for feature(slice_index_methods).

Associated Types

type Immut

Immutable output type.

type Mut

Mutable output type. This is necessary because &mut BitSlice is producible for range indices, but &mut bool is not producable for usize indices.

Loading content...

Required methods

fn get(self, slice: &'a BitSlice<O, T>) -> Option<Self::Immut>

Returns a shared reference to the output at this location, if in bounds.

Parameters

  • self: The index value.
  • slice: The slice under index.

Returns

An immutable output, if self is in bounds; otherwise None.

fn get_mut(self, slice: &'a mut BitSlice<O, T>) -> Option<Self::Mut>

Returns a mutable reference to the output at this location, if in bounds.

Parameters

  • self: The index value.
  • slice: The slice under index.

Returns

A mutable output, if self is in bounds; otherwise None.

unsafe fn get_unchecked(self, slice: &'a BitSlice<O, T>) -> Self::Immut

Returns a shared reference to the output at this location, without performing any bounds checking.

Parameters

  • self: The index value.
  • slice: The slice under index.

Returns

An immutable output.

Safety

As this function does not perform boundary checking, the caller must ensure that self is an index within the boundaries of slice before calling in order to avoid boundary escapes and ensuing safety violations.

unsafe fn get_unchecked_mut(self, slice: &'a mut BitSlice<O, T>) -> Self::Mut

Returns a mutable reference to the output at this location, without performing any bounds checking.

Parameters

  • self: The index value.
  • slice: The slice under index.

Returns

A mutable output.

Safety

As this function does not perform boundary checking, the caller must ensure that self is an index within the boundaries of slice before calling in order to avoid boundary escapes and ensuing safety violations.

fn index(self, slice: &'a BitSlice<O, T>) -> Self::Immut

Returns a shared reference to the output at this location, panicking if out of bounds.

Parameters

  • self: The index value.
  • slice: The slice under index.

Returns

An immutable output.

Panics

This panics if self is out of bounds of slice.

fn index_mut(self, slice: &'a mut BitSlice<O, T>) -> Self::Mut

Returns a mutable reference to the output at this location, panicking if out of bounds.

Parameters

  • self: The index value.
  • slice: The slice under index.

Returns

A mutable output.

Panics

This panics if self is out of bounds of slice.

Loading content...

Implementations on Foreign Types

impl<'a, O, T> BitSliceIndex<'a, O, T> for usize where
    O: 'a + BitOrder,
    T: 'a + BitStore
[src]

type Immut = &'a bool

type Mut = BitMut<'a, O, T>

impl<'a, O, T> BitSliceIndex<'a, O, T> for Range<usize> where
    O: 'a + BitOrder,
    T: 'a + BitStore
[src]

type Immut = &'a BitSlice<O, T>

type Mut = &'a mut BitSlice<O, T>

impl<'a, O, T> BitSliceIndex<'a, O, T> for RangeFrom<usize> where
    O: 'a + BitOrder,
    T: 'a + BitStore
[src]

type Immut = &'a BitSlice<O, T>

type Mut = &'a mut BitSlice<O, T>

impl<'a, O, T> BitSliceIndex<'a, O, T> for RangeTo<usize> where
    O: 'a + BitOrder,
    T: 'a + BitStore
[src]

type Immut = &'a BitSlice<O, T>

type Mut = &'a mut BitSlice<O, T>

impl<'a, O, T> BitSliceIndex<'a, O, T> for RangeInclusive<usize> where
    O: 'a + BitOrder,
    T: 'a + BitStore
[src]

type Immut = &'a BitSlice<O, T>

type Mut = &'a mut BitSlice<O, T>

impl<'a, O, T> BitSliceIndex<'a, O, T> for RangeToInclusive<usize> where
    O: 'a + BitOrder,
    T: 'a + BitStore
[src]

type Immut = &'a BitSlice<O, T>

type Mut = &'a mut BitSlice<O, T>

impl<'a, O, T> BitSliceIndex<'a, O, T> for RangeFull where
    O: 'a + BitOrder,
    T: 'a + BitStore
[src]

RangeFull is the identity function.

type Immut = &'a BitSlice<O, T>

type Mut = &'a mut BitSlice<O, T>

Loading content...

Implementors

Loading content...