[][src]Struct loaf::LoafVec

#[repr(transparent)]pub struct LoafVec<T> { /* fields omitted */ }

Implementations

impl<T> LoafVec<T>[src]

pub fn from_vec(vec: Vec<T>) -> Result<Self, Vec<T>>[src]

pub fn into_vec(self) -> Vec<T>[src]

pub fn as_loaf(&self) -> &Loaf<T>[src]

pub fn as_mut_loaf(&mut self) -> &mut Loaf<T>[src]

pub fn as_mut_slice(&mut self) -> &mut [T][src]

pub fn as_slice(&self) -> &[T][src]

pub fn pop(&mut self) -> Option<T>[src]

pub fn into_boxed_loaf(self) -> Box<Loaf<T>>[src]

Methods from Deref<Target = Loaf<T>>

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

Returns length of the underlying slice

let slice = &[0u8, 1, 2, 3, 4];
let loaf = Loaf::from_slice(slice).unwrap();
assert_eq!(loaf.len(), slice.len());

pub fn first(&self) -> &T[src]

Returns a reference to the first element

let slice = &[0u8, 1, 2, 3, 4];
let loaf = Loaf::from_slice(slice).unwrap();
assert_eq!(*loaf.first(), 0);

pub fn first_mut(&mut self) -> &mut T[src]

Returns a mutable reference to the first element

let slice = &mut [0u8, 1, 2, 3, 4];
let loaf = Loaf::from_slice_mut(slice).unwrap();
*loaf.first_mut() = 42;
assert_eq!(*loaf.first(), 42);

pub fn last(&self) -> &T[src]

Returns a reference to the last element

let slice = &[0u8, 1, 2, 3, 4];
let loaf = Loaf::from_slice(slice).unwrap();
assert_eq!(*loaf.last(), 4);

pub fn last_mut(&mut self) -> &mut T[src]

Returns a mutable reference to the last element

let slice = &mut [0u8, 1, 2, 3, 4];
let loaf = Loaf::from_slice_mut(slice).unwrap();
*loaf.last_mut() = 42;
assert_eq!(*loaf.last(), 42);

pub fn split_first(&self) -> (&T, &[T])[src]

Returns a reference to the first element and the rest of slice

let slice = &[0u8, 1, 2, 3, 4];
let loaf = Loaf::from_slice(slice).unwrap();
let (first, rest) = loaf.split_first();
assert_eq!(*first, 0);
assert_eq!(rest, &[1, 2, 3, 4]);

pub fn split_first_mut(&mut self) -> (&mut T, &mut [T])[src]

Returns a mutable reference to the first element and the rest of slice

let slice = &mut [0u8, 1, 2, 3, 4];
let loaf = Loaf::from_slice_mut(slice).unwrap();
let (first, rest) = loaf.split_first_mut();
*first = 40;
rest[0] = 41;
// slice[0] = 0; // this line does not compile, because slice is borrowed mutably
assert_eq!(*first, 40);
assert_eq!(rest, &[41, 2, 3, 4]);

pub fn as_slice(&self) -> &[T][src]

Casts &Loaf<T> into &[T]

let slice = &[0u8, 1, 2, 3, 4];
let loaf = Loaf::from_slice(slice).unwrap();
assert_eq!(loaf.as_slice(), &[0u8, 1, 2, 3, 4]);

pub fn as_mut_slice(&mut self) -> &mut [T][src]

Casts &mut Loaf<T> into &mut [T]

let slice = &mut [0u8, 1, 2, 3, 4];
let loaf = Loaf::from_slice_mut(slice).unwrap();
loaf.loaf[0] = 42;
loaf.rest[3] = 14;
assert_eq!(loaf.as_slice(), &[42u8, 1, 2, 3, 14]);

Trait Implementations

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

impl<T> Deref for LoafVec<T>[src]

type Target = Loaf<T>

The resulting type after dereferencing.

impl<T> DerefMut for LoafVec<T>[src]

Auto Trait Implementations

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

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

impl<T> Unpin for LoafVec<T> where
    T: Unpin

Blanket Implementations

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

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

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

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

impl<T, U> Into<U> for T where
    U: From<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.