Struct PointerArray

Source
pub struct PointerArray<'a, const N: usize = 4> { /* private fields */ }

Implementations§

Source§

impl<'a, const N: usize> PointerArray<'a, N>

Source

pub const fn new() -> Self

Construct an empty PointerArray.

Array have a length of 4usize by default.

Source§

impl<'a, const N: usize> PointerArray<'a, N>

Source

pub fn insert_mut<'b, T: 'static>( self, value: &'b mut T, ) -> Result<PointerArray<'b, N>, Full<'a, N>>
where 'a: 'b,

Insert a &mut T to array. This method would consume Self.

If the array have a &mut T already it would replace it and the old one is dropped. *. only the &mut T would be dropped and destructor of T does not run.

On Ok(Self) the array with reference successfully inserted would returned. (Self’s lifetime is shrink to the same of input &mut T).

On Err(Full) the array without modification would be returned. See Full::into_inner for detail.

Source

pub fn insert_ref<'b, T: 'static>( self, value: &'b T, ) -> Result<PointerArray<'b, N>, Full<'a, N>>
where 'a: 'b,

The &T version of Self::insert_mut. See it for more detail.

Source

pub fn remove_ref<T: 'static>(&mut self) -> Option<&'a T>

&T version of Self::remove_mut. See it for detail.

Source

pub fn remove_mut<T: 'static>(&mut self) -> Option<&'a mut T>

Remove &mut T from array. Return None when there is no according type in array.

Source

pub fn get<T: 'static>(&self) -> Option<&'a T>

Get &T without removing it from the array.

&T can be get from either insert with Self::insert_mut or Self::insert_ref.

Source

pub fn get_mut<T: 'static>(&mut self) -> Option<&'a mut T>

Get &mut T without removing it from the array.

&mut T can be get from insert with Self::insert_mut.

Trait Implementations§

Source§

impl Default for PointerArray<'_>

Source§

fn default() -> Self

Returns the “default value” for a type. Read more

Auto Trait Implementations§

§

impl<'a, const N: usize> Freeze for PointerArray<'a, N>

§

impl<'a, const N: usize> RefUnwindSafe for PointerArray<'a, N>

§

impl<'a, const N: usize = 4> !Send for PointerArray<'a, N>

§

impl<'a, const N: usize = 4> !Sync for PointerArray<'a, N>

§

impl<'a, const N: usize> Unpin for PointerArray<'a, N>

§

impl<'a, const N: usize> UnwindSafe for PointerArray<'a, 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.