SingleItemStorage

Struct SingleItemStorage 

Source
pub struct SingleItemStorage<T>(pub T);
Expand description

A structure that holds one, and only one T.

Behaves like [T; 1] but has additional Default and From implementations.

Tuple Fields§

§0: T

Trait Implementations§

Source§

impl<T> AsMut<[T]> for SingleItemStorage<T>

Source§

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

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

impl<T> AsRef<[T]> for SingleItemStorage<T>

Source§

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

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

impl<T> Capacity for SingleItemStorage<T>

let mut structure = cl_aux::doc_tests::single_item_storage();
assert_eq!(cl_aux::Capacity::capacity(&structure), 1);
Source§

fn capacity(&self) -> usize

The number of elements the implementation has pre-allocated as an internal buffer. Not necessarily the current number of inserted elements.
Source§

impl<T> CapacityUpperBound for SingleItemStorage<T>

let mut structure = cl_aux::doc_tests::single_item_storage();
assert_eq!(cl_aux::Capacity::capacity(&structure), 1);
Source§

const CAPACITY_UPPER_BOUND: usize = 1usize

The maximum theoretical number of elements a type implementation is able to store.
Source§

fn capacity_upper_bound(&self) -> usize

Instance method representing Self::CAPACITY_UPPER_BOUND.
Source§

impl<T: Debug> Debug for SingleItemStorage<T>

Source§

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

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

impl<T: Default> Default for SingleItemStorage<T>

Source§

fn default() -> SingleItemStorage<T>

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

impl<T> From<T> for SingleItemStorage<T>

Source§

fn from(from: T) -> Self

Converts to this type from the input type.
Source§

impl<T> Get for SingleItemStorage<T>

let structure = cl_aux::doc_tests::single_item_storage();
assert_eq!(cl_aux::Get::get(&structure, 0), Ok(&1));
Source§

type Error = Error

Error
Source§

type Input = usize

Input
Source§

type Output<'output> = &'output T where Self: 'output

Output
Source§

fn get(&self, _: Self::Input) -> Result<Self::Output<'_>, Self::Error>

Returns an immutable inner reference of a derived element.
Source§

impl<T> GetMut for SingleItemStorage<T>

let mut structure = cl_aux::doc_tests::single_item_storage();
assert_eq!(cl_aux::GetMut::get_mut(&mut structure, 0), Ok(&mut 1));
Source§

type Error = Error

Error
Source§

type Input = usize

Input
Source§

type Output<'output> = &'output mut T where Self: 'output

Output
Source§

fn get_mut( &mut self, input: Self::Input, ) -> Result<Self::Output<'_>, Self::Error>

Returns an mutable inner reference of a derived element.
Source§

impl<T> Iter for SingleItemStorage<T>

let structure = cl_aux::doc_tests::single_item_storage();
assert_eq!(cl_aux::Iter::iter(&structure).next().unwrap(), &1);
Source§

type Output<'iter> = Iter<'iter, T> where T: 'iter

Iterator
Source§

fn iter(&self) -> Self::Output<'_>

Returns a new iterator that refers inner elements.
Source§

impl<T> Length for SingleItemStorage<T>

let structure = cl_aux::doc_tests::single_item_storage();
assert_eq!(cl_aux::Length::length(&structure), 1);
Source§

fn length(&self) -> usize

Holds a certain number of elements.
Source§

impl<T: PartialEq> PartialEq for SingleItemStorage<T>

Source§

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

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

fn ne(&self, other: &Rhs) -> bool

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

impl<T: PartialOrd> PartialOrd for SingleItemStorage<T>

Source§

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

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

fn lt(&self, other: &Rhs) -> bool

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

fn le(&self, other: &Rhs) -> bool

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

fn gt(&self, other: &Rhs) -> bool

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

fn ge(&self, other: &Rhs) -> bool

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

impl<T> SingleTypeStorage for SingleItemStorage<T>

Source§

type Item = T

Storage item
Source§

impl<T> SizeHint for SingleItemStorage<T>

let structure = cl_aux::doc_tests::single_item_storage();
assert_eq!(cl_aux::SizeHint::size_hint(&structure), (1, Some(1)));
Source§

fn size_hint(&self) -> (usize, Option<usize>)

Has the same semantics of Iterator::size_hint.
Source§

impl<T: Eq> Eq for SingleItemStorage<T>

Source§

impl<T> StructuralPartialEq for SingleItemStorage<T>

Auto Trait Implementations§

§

impl<T> Freeze for SingleItemStorage<T>
where T: Freeze,

§

impl<T> RefUnwindSafe for SingleItemStorage<T>
where T: RefUnwindSafe,

§

impl<T> Send for SingleItemStorage<T>
where T: Send,

§

impl<T> Sync for SingleItemStorage<T>
where T: Sync,

§

impl<T> Unpin for SingleItemStorage<T>
where T: Unpin,

§

impl<T> UnwindSafe for SingleItemStorage<T>
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> From<!> for T

Source§

fn from(t: !) -> T

Converts to this type from the input type.
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.