[][src]Struct framering::RingFrame

pub struct RingFrame<'ring, T, Cap: Capacity> { /* fields omitted */ }

An immutable frame which does not allow elements to be appended

Implementations

impl<'ring, T, Cap: Capacity> RingFrame<'ring, T, Cap>[src]

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

Length in elements of the frame

Example

let mut ring = FramedRing::<i32, Pow2Capacity>::new();
let mut frame = ring.frame();
frame.push(1);
frame.push(2);
frame.push(3);
assert_eq!(frame.as_ref().len(), 3);

pub fn get(&self, index: usize) -> Option<&T>[src]

Gets the given item in the frame as a reference, or None if out of bounds

Example

let mut ring = FramedRing::<i32, Pow2Capacity>::new();
let mut frame = ring.frame();
frame.push(1);
let frame_ro = frame.downgrade();
assert_eq!(*frame_ro.get(0).unwrap(), 1);
assert_eq!(frame_ro.get(1), None);

pub fn get_mut(&mut self, index: usize) -> Option<&mut T>[src]

Gets the given item in the frame as a mutable reference, or None if out of bounds

Example

let mut ring = FramedRing::<i32, Pow2Capacity>::new();
let mut frame = ring.frame();
frame.push(1);
let mut frame_ro = frame.downgrade();
assert_eq!(*frame_ro.get(0).unwrap(), 1);
*frame_ro.get_mut(0).unwrap() = 2;
assert_eq!(*frame_ro.get(0).unwrap(), 2);

pub unsafe fn get_unchecked(&self, index: usize) -> &T[src]

Gets the given item in the frame as a reference, performing no bounds checking

Example

let mut ring = FramedRing::<i32, Pow2Capacity>::new();
let mut frame = ring.frame();
frame.push(1);
let frame_ro = frame.downgrade();
assert_eq!(unsafe {*frame_ro.get_unchecked(0)}, 1);

pub unsafe fn get_unchecked_mut(&mut self, index: usize) -> &mut T[src]

Gets the given item in the frame as a mutable reference, performing no bounds checking

Example

let mut ring = FramedRing::<i32, Pow2Capacity>::new();
let mut frame = ring.frame();
frame.push(1);
let mut frame_ro = frame.downgrade();
assert_eq!(*frame_ro.get(0).unwrap(), 1);
unsafe {*frame_ro.get_unchecked_mut(0) = 2};
assert_eq!(*frame_ro.get(0).unwrap(), 2);

pub fn iter<'a>(&'a self) -> RingFrameIter<'a, T, Cap>

Notable traits for RingFrameIter<'a, T, Cap>

impl<'a, T, Cap: Capacity> Iterator for RingFrameIter<'a, T, Cap> type Item = &'a T;
[src]

An iterator over all of the frame elements

Example

let mut ring = FramedRing::<i32, Pow2Capacity>::new();
let mut frame = ring.frame();
frame.push(1);
frame.push(2);
frame.push(3);
assert_eq!(frame.as_ref().iter().copied().collect::<Vec<i32>>(), vec![1, 2, 3]);

Trait Implementations

impl<'ring, T, Cap: Capacity> AsRef<RingFrame<'ring, T, Cap>> for RingFrameMut<'ring, T, Cap>[src]

impl<'ring, T, Cap: Capacity> Drop for RingFrame<'ring, T, Cap>[src]

impl<'ring, T, Cap: Capacity> From<RingFrameMut<'ring, T, Cap>> for RingFrame<'ring, T, Cap>[src]

impl<'ring, T, Cap: Capacity> IntoIterator for RingFrame<'ring, T, Cap>[src]

type Item = T

The type of the elements being iterated over.

type IntoIter = RingFrameIntoIter<'ring, T, Cap>

Which kind of iterator are we turning this into?

Auto Trait Implementations

impl<'ring, T, Cap> !RefUnwindSafe for RingFrame<'ring, T, Cap>[src]

impl<'ring, T, Cap> !Send for RingFrame<'ring, T, Cap>[src]

impl<'ring, T, Cap> !Sync for RingFrame<'ring, T, Cap>[src]

impl<'ring, T, Cap> Unpin for RingFrame<'ring, T, Cap>[src]

impl<'ring, T, Cap> !UnwindSafe for RingFrame<'ring, T, Cap>[src]

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, 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.