Vect

Struct Vect 

Source
pub struct Vect<T, S>
where S: Size,
{ /* private fields */ }
Expand description

The type-safe vector with type-level length.

Implementations§

Source§

impl<T> Vect<T, U0>

Source

pub fn new() -> Self

Creates an empty vector with static length.

Source

pub fn with_capacity(capacity: usize) -> Self

Creates an empty vector with static length and with specified capacity.

Source

pub fn len(&self) -> usize

Gets the number of elements.

Source§

impl<T> Vect<T, Dyn>

Source

pub fn new() -> Self

Creates an empty vector with dynamic length.

Source

pub fn from_vec(data: Vec<T>) -> Self

Creates a vector from Vec.

Source

pub fn with_capacity(capacity: usize) -> Self

Creates an empty vector with dynamic length and with specified capacity.

Source

pub fn len(&self) -> usize

Gets the number of elements.

Source

pub fn into_static<S>(self) -> Option<Vect<T, S>>
where S: Unsigned + Size,

Converts a vector with static length.

The vector size must be equal to the specified static size. Otherwise it returns None.

Source§

impl<T, U, B> Vect<T, UInt<U, B>>
where U: Unsigned, B: Bit,

Source

pub fn len(&self) -> usize

Gets the number of elements.

Source§

impl<T, S> Vect<T, S>
where S: Size,

Source

pub fn push(self, elem: T) -> PushImplOp<Self, T>
where (): PushImpl<Self, T>,

Appends an element to the end of the vector.

Source

pub fn pop(self) -> PopImplOp<Self>
where (): PopImpl<Self>,

Removes an element from the end of the vector.

Source

pub fn get<'a, I>(&'a self, index: I) -> GetImplOp<'a, Self, I::Output>
where I: IntoSize, (): GetImpl<'a, Self, I::Output>,

Returns a reference to an element depending on the index.

If both length and index have static sizes, it returns &T. Otherwise, it returns Option<&T>.

Source

pub fn insert<I>(self, index: I, elem: T) -> InsertImplOp<Self, I::Output, T>
where I: IntoSize, (): InsertImpl<Self, I::Output, T>,

Inserts an element at specified index.

If both length and index have static sizes, it checks if the index is valid in compile time. Otherwise, it panics if the index is out of bound.

Source

pub fn remove<I>(self, index: I) -> RemoveImplOp<Self, I::Output>
where I: IntoSize, (): RemoveImpl<Self, I::Output>,

Removes an element at specified index.

If both length and index have static sizes, it checks if the index is valid in compile time. Otherwise, it panics if the index is out of bound.

Source

pub fn into_dyn(self) -> Vect<T, Dyn>

Converts to a vector with dynamic length type.

Source

pub fn into_vec(self) -> Vec<T>

Converts to Vec.

Trait Implementations§

Source§

impl<T: Clone, S> Clone for Vect<T, S>
where S: Size + Clone,

Source§

fn clone(&self) -> Vect<T, S>

Returns a duplicate of the value. Read more
1.0.0 · Source§

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

Performs copy-assignment from source. Read more
Source§

impl<T: Debug, S> Debug for Vect<T, S>
where S: Size + Debug,

Source§

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

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

impl<'a, T, S, Index> GetImpl<'a, Vect<T, S>, Index> for ()
where S: Size, Index: Size, (): GetPrivate<'a, Vect<T, S>, Index, CheckIndexOp<S, Index>> + CheckIndex<S, Index>,

Source§

type Output = <() as GetPrivate<'a, Vect<T, S>, Index, <() as CheckIndex<S, Index>>::Output>>::Output

Source§

fn impl_get(input: &'a Vect<T, S>, index: Index) -> Self::Output

Source§

impl<T: Hash, S> Hash for Vect<T, S>
where S: Size + Hash,

Source§

fn hash<__H: Hasher>(&self, state: &mut __H)

Feeds this value into the given Hasher. Read more
1.3.0 · Source§

fn hash_slice<H>(data: &[Self], state: &mut H)
where H: Hasher, Self: Sized,

Feeds a slice of this type into the given Hasher. Read more
Source§

impl<S, Index, Item> InsertImpl<Vect<Item, S>, Index, Item> for ()
where S: Size, Index: Size, (): IncreaseOne<S> + CheckIndexInclusive<S, Index>,

Source§

type Output = Vect<Item, <() as IncreaseOne<S>>::Output>

Source§

fn impl_insert(input: Vect<Item, S>, index: Index, item: Item) -> Self::Output

Source§

impl<T: Ord, S> Ord for Vect<T, S>
where S: Size + Ord,

Source§

fn cmp(&self, other: &Vect<T, S>) -> Ordering

This method returns an Ordering between self and other. Read more
1.21.0 · Source§

fn max(self, other: Self) -> Self
where Self: Sized,

Compares and returns the maximum of two values. Read more
1.21.0 · Source§

fn min(self, other: Self) -> Self
where Self: Sized,

Compares and returns the minimum of two values. Read more
1.50.0 · Source§

fn clamp(self, min: Self, max: Self) -> Self
where Self: Sized,

Restrict a value to a certain interval. Read more
Source§

impl<T: PartialEq, S> PartialEq for Vect<T, S>
where S: Size + PartialEq,

Source§

fn eq(&self, other: &Vect<T, S>) -> 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, S> PartialOrd for Vect<T, S>
where S: Size + PartialOrd,

Source§

fn partial_cmp(&self, other: &Vect<T, S>) -> 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<__TYP_GENERIC_0, __TYP_GENERIC_1> Pop<Vect<__TYP_GENERIC_0, __TYP_GENERIC_1>> for ()
where (): DecreaseOne<__TYP_GENERIC_1> + __TYP_MatchArm_0<__TYP_GENERIC_0, __TYP_GENERIC_1, <() as DecreaseOne<__TYP_GENERIC_1>>::Output>, Vect<__TYP_GENERIC_0, __TYP_GENERIC_1>:, __TYP_GENERIC_0:, __TYP_GENERIC_1: Size,

Source§

type Output = <() as __TYP_MatchArm_0<__TYP_GENERIC_0, __TYP_GENERIC_1, <() as DecreaseOne<__TYP_GENERIC_1>>::Output>>::Output

Source§

impl<__TYP_GENERIC_0, __TYP_GENERIC_1> Push<Vect<__TYP_GENERIC_0, __TYP_GENERIC_1>> for ()
where __TYP_GENERIC_0:, <() as IncreaseOne<__TYP_GENERIC_1>>::Output: Size, Vect<__TYP_GENERIC_0, __TYP_GENERIC_1>:, __TYP_GENERIC_1: Size, (): IncreaseOne<__TYP_GENERIC_1>,

Source§

type Output = Vect<__TYP_GENERIC_0, <() as IncreaseOne<__TYP_GENERIC_1>>::Output>

Source§

impl<T, S> PushImpl<Vect<T, S>, T> for ()
where S: Size, (): Push<Vect<T, S>>, PushOp<Vect<T, S>>: VectFactory<T>,

Source§

type Output = <() as Push<Vect<T, S>>>::Output

Source§

fn impl_push(input: Vect<T, S>, item: T) -> Self::Output

Source§

impl<S, Index, Item> RemoveImpl<Vect<Item, S>, Index> for ()
where S: Size, Index: Size, (): DecreaseOne<S> + CheckIndex<S, Index>,

Source§

type Output = (Vect<Item, <() as DecreaseOne<S>>::Output>, Item)

Source§

fn impl_remove(input: Vect<Item, S>, index: Index) -> Self::Output

Source§

impl<T, S> VectFactory<T> for Vect<T, S>
where S: Size,

Source§

fn from_vec(vec: Vec<T>) -> Self

Source§

impl<T: Eq, S> Eq for Vect<T, S>
where S: Size + Eq,

Source§

impl<T, S> StructuralPartialEq for Vect<T, S>
where S: Size,

Auto Trait Implementations§

§

impl<T, S> Freeze for Vect<T, S>

§

impl<T, S> RefUnwindSafe for Vect<T, S>

§

impl<T, S> Send for Vect<T, S>
where S: Send, T: Send,

§

impl<T, S> Sync for Vect<T, S>
where S: Sync, T: Sync,

§

impl<T, S> Unpin for Vect<T, S>
where S: Unpin, T: Unpin,

§

impl<T, S> UnwindSafe for Vect<T, S>
where S: UnwindSafe, 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, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. 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> Same for T

Source§

type Output = T

Should always be Self
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.