wiwi::chain

Struct ArrayChain

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

Implementations§

Source§

impl<T, const N: usize> ArrayChain<T, N>

Source§

impl<T, const N: usize> ArrayChain<MaybeUninit<T>, N>

Source

pub unsafe fn assume_init(self) -> ArrayChain<T, N>

Assumes all slots inside the array are initialised according to T’s requirements, and converts into an array of T

Note: this implementation is currently subpar, as it does fully copy self into a new container using ptr::read. We have to do this because, at the time of writing:

  • transmute is a bit too dumb, and is not able to prove [T; N] and [MaybeUninit<T>; N] are guaranteed to be equal sized, even though we can see and prove it
  • transmute_unchecked is like transmute but without that compile time size check, but it is unstable, and according to a code comment will almost certainly never be stabilised (reasoning is that it’s too unsafe, too much power to give users :p, and to hopefully find other methods for doing things without it so that it isn’t needed)
  • MaybeUninit::array_assume_init is unstable (it internally makes use of transmute_unchecked)

We don’t know of any other option than to perform a ptr cast, then read from it.

§Safety

All slots in self must be fully initialised with valid values of T.

Trait Implementations§

Source§

impl<T, const N: usize> AsChainInner<[T; N]> for ArrayChain<T, N>

Source§

fn as_inner(&self) -> &[T; N]

Source§

fn as_inner_mut(&mut self) -> &mut [T; N]

Source§

impl<T, const N: usize> AsMut<[T; N]> for ArrayChain<T, N>

Source§

fn as_mut(&mut self) -> &mut [T; N]

Converts this type into a mutable reference of the (usually inferred) input type.
Source§

impl<T, const N: usize> AsRef<[T; N]> for ArrayChain<T, N>

Source§

fn as_ref(&self) -> &[T; N]

Converts this type into a shared reference of the (usually inferred) input type.
Source§

impl<T, const N: usize> Chain for ArrayChain<T, N>

Source§

type Inner = [T; N]

Source§

fn into_inner(self) -> Self::Inner

Source§

fn from_inner(inner: Self::Inner) -> Self

Source§

fn as_inner(&self) -> &Self::Inner

Source§

fn as_inner_mut(&mut self) -> &mut Self::Inner

Source§

fn with_inner<F, Void>(self, f: F) -> Self
where F: FnOnce(&mut Self::Inner) -> Void,

Takes a closure that is called, passing in a reference to the inner value Read more
Source§

impl<T, const N: usize> Clone for ArrayChain<T, N>
where [T; N]: Clone,

Source§

fn clone(&self) -> Self

Returns a copy of the value. Read more
Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl<T, const N: usize> Debug for ArrayChain<T, N>
where [T; N]: Debug,

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
Source§

impl<T, const N: usize> Default for ArrayChain<T, N>
where [T; N]: Default,

Source§

fn default() -> Self

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

impl<T, const N: usize> Display for ArrayChain<T, N>
where [T; N]: Display,

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
Source§

impl<T, const N: usize> From<&[T; N]> for ArrayChain<T, N>
where [T; N]: Clone,

Source§

fn from(inner: &[T; N]) -> Self

Converts to this type from the input type.
Source§

impl<T, const N: usize> From<&ArrayChain<T, N>> for [T; N]
where [T; N]: Clone,

Source§

fn from(chain: &ArrayChain<T, N>) -> Self

Converts to this type from the input type.
Source§

impl<T, const N: usize> From<&mut [T; N]> for ArrayChain<T, N>
where [T; N]: Clone,

Source§

fn from(inner: &mut [T; N]) -> Self

Converts to this type from the input type.
Source§

impl<T, const N: usize> From<&mut ArrayChain<T, N>> for [T; N]
where [T; N]: Clone,

Source§

fn from(chain: &mut ArrayChain<T, N>) -> Self

Converts to this type from the input type.
Source§

impl<T, const N: usize> From<[T; N]> for ArrayChain<T, N>

Source§

fn from(inner: [T; N]) -> Self

Converts to this type from the input type.
Source§

impl<T, const N: usize> From<ArrayChain<T, N>> for [T; N]

Source§

fn from(chain: ArrayChain<T, N>) -> Self

Converts to this type from the input type.
Source§

impl<T, const N: usize> PartialEq<[T; N]> for ArrayChain<T, N>

Source§

fn eq(&self, other: &[T; N]) -> bool

Tests for self and other values to be equal, and is used by ==.
Source§

fn ne(&self, other: &[T; N]) -> bool

Tests for !=. The default implementation is almost always sufficient, and should not be overridden without very good reason.
Source§

impl<T, const N: usize> PartialEq<ArrayChain<T, N>> for [T; N]

Source§

fn eq(&self, other: &ArrayChain<T, N>) -> bool

Tests for self and other values to be equal, and is used by ==.
Source§

fn ne(&self, other: &ArrayChain<T, N>) -> bool

Tests for !=. The default implementation is almost always sufficient, and should not be overridden without very good reason.
Source§

impl<T, const N: usize> PartialEq for ArrayChain<T, N>

Source§

fn eq(&self, other: &ArrayChain<T, N>) -> bool

Tests for self and other values to be equal, and is used by ==.
Source§

fn ne(&self, other: &ArrayChain<T, N>) -> bool

Tests for !=. The default implementation is almost always sufficient, and should not be overridden without very good reason.
Source§

impl<T, const N: usize> PartialOrd<[T; N]> for ArrayChain<T, N>

Source§

fn partial_cmp(&self, other: &[T; N]) -> Option<Ordering>

This method returns an ordering between self and other values if one exists. Read more
Source§

fn lt(&self, other: &[T; N]) -> bool

Tests less than (for self and other) and is used by the < operator. Read more
Source§

fn le(&self, other: &[T; N]) -> bool

Tests less than or equal to (for self and other) and is used by the <= operator. Read more
Source§

fn gt(&self, other: &[T; N]) -> bool

Tests greater than (for self and other) and is used by the > operator. Read more
Source§

fn ge(&self, other: &[T; N]) -> bool

Tests greater than or equal to (for self and other) and is used by the >= operator. Read more
Source§

impl<T, const N: usize> PartialOrd<ArrayChain<T, N>> for [T; N]

Source§

fn partial_cmp(&self, other: &ArrayChain<T, N>) -> Option<Ordering>

This method returns an ordering between self and other values if one exists. Read more
Source§

fn lt(&self, other: &ArrayChain<T, N>) -> bool

Tests less than (for self and other) and is used by the < operator. Read more
Source§

fn le(&self, other: &ArrayChain<T, N>) -> bool

Tests less than or equal to (for self and other) and is used by the <= operator. Read more
Source§

fn gt(&self, other: &ArrayChain<T, N>) -> bool

Tests greater than (for self and other) and is used by the > operator. Read more
Source§

fn ge(&self, other: &ArrayChain<T, N>) -> bool

Tests greater than or equal to (for self and other) and is used by the >= operator. Read more
Source§

impl<T, const N: usize> PartialOrd for ArrayChain<T, N>

Source§

fn partial_cmp(&self, other: &ArrayChain<T, N>) -> Option<Ordering>

This method returns an ordering between self and other values if one exists. Read more
Source§

fn lt(&self, other: &ArrayChain<T, N>) -> bool

Tests less than (for self and other) and is used by the < operator. Read more
Source§

fn le(&self, other: &ArrayChain<T, N>) -> bool

Tests less than or equal to (for self and other) and is used by the <= operator. Read more
Source§

fn gt(&self, other: &ArrayChain<T, N>) -> bool

Tests greater than (for self and other) and is used by the > operator. Read more
Source§

fn ge(&self, other: &ArrayChain<T, N>) -> bool

Tests greater than or equal to (for self and other) and is used by the >= operator. Read more
Source§

impl<T, const N: usize> Copy for ArrayChain<T, N>
where [T; N]: Copy,

Auto Trait Implementations§

§

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

§

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

§

impl<T, const N: usize> Send for ArrayChain<T, N>
where T: Send,

§

impl<T, const N: usize> Sync for ArrayChain<T, N>
where T: Sync,

§

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

§

impl<T, const N: usize> UnwindSafe for ArrayChain<T, N>
where T: UnwindSafe,

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> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dst: *mut T)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dst. Read more
Source§

impl<T> Encode for T

Source§

fn encode<E>(self) -> <E as Encoding>::EncodeOutput
where T: Encodable<E>, E: Encoding,

Source§

fn decode<E>(self) -> <E as Encoding>::DecodeOutput
where T: Decodable<E>, E: Encoding,

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> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
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.