Struct SmartBuffer

Source
pub struct SmartBuffer<T, const N: usize>
where T: Clone,
{ /* private fields */ }

Implementations§

Source§

impl<T, const N: usize> SmartBuffer<T, N>
where T: Clone,

Source

pub fn clear(&mut self)

Clears all values to the given default value.

Source

pub fn push(&mut self, other: T)

Safely push a value into the SmartBuffer

Source

pub fn set_size(&mut self, size: usize)

Sets the size of the buffer (does not reduce capacity)

Source

pub fn insert_slice(&mut self, slice: &[T])

Safely inserts a slice of data, starting at the size.

Source

pub fn insert_slice_at(&mut self, slice: &[T], index: usize)

Safely inserts a slice of data at an index;

Source

pub fn insert_arr<const M: usize>(&mut self, arr: &[T; M])

Safely inserts an array, starting at the size.

Source

pub fn insert(&mut self, other: T, index: usize)

Safely insert a value into the SmartBuffer

Source

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

Safely get a value at an index

Source

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

Unsafely get a reference to a value at an index. An index too large will result in a fault

Source

pub unsafe fn get_mut_unchecked(&mut self, index: usize) -> &mut T

Unsafely get a mutable

Source

pub fn as_mut_ptr(self) -> *mut Self

Source

pub fn new(value: T, len: usize) -> Self
where T: Copy + Clone,

Source

pub fn from_arr(buf: [T; N], len: usize) -> Self
where T: Clone,

Creates a SmartBuffer from an array

Source§

impl<T, const N: usize> SmartBuffer<T, N>
where T: Clone + PartialEq,

Source

pub fn calc_size(&mut self)

Recalculates the size

Trait Implementations§

Source§

impl<T, const N: usize> Drop for SmartBuffer<T, N>
where T: Clone,

Source§

fn drop(&mut self)

Executes the destructor for this type. Read more
Source§

impl<T, const N: usize> Index<usize> for &SmartBuffer<T, N>
where T: Clone,

Source§

type Output = T

The returned type after indexing.
Source§

fn index(&self, index: usize) -> &Self::Output

Performs the indexing (container[index]) operation. Read more
Source§

impl<T, const N: usize> Index<usize> for SmartBuffer<T, N>
where T: Clone,

Source§

type Output = T

The returned type after indexing.
Source§

fn index(&self, index: usize) -> &Self::Output

Performs the indexing (container[index]) operation. Read more
Source§

impl<T, const N: usize> IndexMut<usize> for SmartBuffer<T, N>
where T: Clone,

Source§

fn index_mut(&mut self, index: usize) -> &mut Self::Output

Performs the mutable indexing (container[index]) operation. Read more
Source§

impl<T, const N: usize> Into<Vec<T>> for SmartBuffer<T, N>
where T: Clone,

Source§

fn into(self) -> Vec<T>

Converts this type into the (usually inferred) input type.
Source§

impl<'a, T, const N: usize> IntoIterator for &'a SmartBuffer<T, N>
where T: Clone,

Source§

fn into_iter(self) -> Self::IntoIter

Creates a consuming Iterator

Source§

type Item = &'a T

The type of the elements being iterated over.
Source§

type IntoIter = SmartBufferIterRef<'a, T, N>

Which kind of iterator are we turning this into?
Source§

impl<'a, T, const N: usize> IntoIterator for &'a mut SmartBuffer<T, N>
where T: Clone,

Source§

fn into_iter(self) -> Self::IntoIter

Creates a consuming Iterator

Source§

type Item = &'a mut T

The type of the elements being iterated over.
Source§

type IntoIter = SmartBufferIterRefMut<'a, T, N>

Which kind of iterator are we turning this into?
Source§

impl<T, const N: usize> IntoIterator for SmartBuffer<T, N>
where T: Clone,

Source§

fn into_iter(self) -> Self::IntoIter

Creates a consuming Iterator

Source§

type Item = T

The type of the elements being iterated over.
Source§

type IntoIter = SmartBufferIter<T, N>

Which kind of iterator are we turning this into?

Auto Trait Implementations§

§

impl<T, const N: usize> Freeze for SmartBuffer<T, N>
where T: Freeze,

§

impl<T, const N: usize> RefUnwindSafe for SmartBuffer<T, N>
where T: RefUnwindSafe,

§

impl<T, const N: usize> !Send for SmartBuffer<T, N>

§

impl<T, const N: usize> !Sync for SmartBuffer<T, N>

§

impl<T, const N: usize> Unpin for SmartBuffer<T, N>
where T: Unpin,

§

impl<T, const N: usize> UnwindSafe for SmartBuffer<T, N>

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.