[−][src]Struct framering::RingFrame
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]
Notable traits for RingFrameIter<'a, T, Cap>
impl<'a, T, Cap: Capacity> Iterator for RingFrameIter<'a, T, Cap> type Item = &'a T;
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]
pub fn from(rfm: RingFrameMut<'ring, T, Cap>) -> Self
[src]
impl<'ring, T, Cap: Capacity> IntoIterator for RingFrame<'ring, T, Cap>
[src]
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]
T: 'static + ?Sized,
impl<T> Borrow<T> for T where
T: ?Sized,
[src]
T: ?Sized,
impl<T> BorrowMut<T> for T where
T: ?Sized,
[src]
T: ?Sized,
pub fn borrow_mut(&mut self) -> &mut T
[src]
impl<T> From<T> for T
[src]
impl<T, U> Into<U> for T where
U: From<T>,
[src]
U: From<T>,
impl<T, U> TryFrom<U> for T where
U: Into<T>,
[src]
U: Into<T>,
type Error = Infallible
The type returned in the event of a conversion error.
pub fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>
[src]
impl<T, U> TryInto<U> for T where
U: TryFrom<T>,
[src]
U: TryFrom<T>,