Struct andex::AndexableArray

source ·
pub struct AndexableArray<A, Item, const SIZE: usize>(/* private fields */);
Expand description

Array wrapper indexable by the provided Andex type.

Example:

use andex::*;

enum MyIdxMarker {}
type MyIdx = Andex<MyIdxMarker, 12>;

// Create the array wrapper:
type MyU32 = AndexableArray<MyIdx, u32, { MyIdx::SIZE }>;

// We can create other arrays with the same Andex type:
type MyF64 = AndexableArray<MyIdx, f64, { MyIdx::SIZE }>;

// Create a default array:
let myu32 = MyU32::default();
// Print the first element:
const first : MyIdx = MyIdx::new::<0>();
println!("{:?}", myu32[first]);
// Iterate and print all elements:
for i in MyIdx::iter() {
    println!("{:?}", myu32[i]);
}
// Print the whole array
println!("{:?}", myu32);

Implementations§

source§

impl<A, Item, const SIZE: usize> AndexableArray<A, Item, SIZE>

source

pub fn iter(&self) -> impl Iterator<Item = &Item>

Returns an iterator over the AnexableArray.

Trait Implementations§

source§

impl<A, Item, const SIZE: usize> AsMut<[Item; SIZE]> for AndexableArray<A, Item, SIZE>

source§

fn as_mut(&mut self) -> &mut [Item; SIZE]

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

impl<A, Item, const SIZE: usize> AsRef<[Item; SIZE]> for AndexableArray<A, Item, SIZE>

source§

fn as_ref(&self) -> &[Item; SIZE]

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

impl<A, Item: Copy, const SIZE: usize> Clone for AndexableArray<A, Item, SIZE>

source§

fn clone(&self) -> Self

Returns a copy 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<A: Debug, Item: Debug, const SIZE: usize> Debug for AndexableArray<A, Item, SIZE>

source§

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

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

impl<A, Item: Default + Copy, const SIZE: usize> Default for AndexableArray<A, Item, SIZE>

source§

fn default() -> Self

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

impl<A, Item, const SIZE: usize> From<&[Item; SIZE]> for AndexableArray<A, Item, SIZE>
where Item: Copy,

source§

fn from(array: &[Item; SIZE]) -> Self

Converts to this type from the input type.
source§

impl<A, Item, const SIZE: usize> From<&AndexableArray<A, Item, SIZE>> for [Item; SIZE]
where Item: Copy,

source§

fn from(andexable_array: &AndexableArray<A, Item, SIZE>) -> [Item; SIZE]

Converts to this type from the input type.
source§

impl<A, Item, const SIZE: usize> From<[Item; SIZE]> for AndexableArray<A, Item, SIZE>

source§

fn from(array: [Item; SIZE]) -> Self

Converts to this type from the input type.
source§

impl<A, Item, const SIZE: usize> From<AndexableArray<A, Item, SIZE>> for [Item; SIZE]
where Item: Copy,

source§

fn from(andexable_array: AndexableArray<A, Item, SIZE>) -> [Item; SIZE]

Converts to this type from the input type.
source§

impl<'a, A, Item: 'a + Copy, const SIZE: usize> FromIterator<&'a Item> for AndexableArray<A, Item, SIZE>

source§

fn from_iter<I: IntoIterator<Item = &'a Item>>(intoiter: I) -> Self

Creates a value from an iterator. Read more
source§

impl<A, Item, const SIZE: usize> FromIterator<Item> for AndexableArray<A, Item, SIZE>

source§

fn from_iter<I: IntoIterator<Item = Item>>(intoiter: I) -> Self

Creates a value from an iterator. Read more
source§

impl<A, Item, const SIZE: usize> Index<&Andex<A, SIZE>> for AndexableArray<Andex<A, SIZE>, Item, SIZE>

§

type Output = Item

The returned type after indexing.
source§

fn index(&self, index: &Andex<A, SIZE>) -> &Self::Output

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

impl<A, Item, const SIZE: usize> Index<Andex<A, SIZE>> for AndexableArray<Andex<A, SIZE>, Item, SIZE>

§

type Output = Item

The returned type after indexing.
source§

fn index(&self, index: Andex<A, SIZE>) -> &Self::Output

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

impl<A, Item, const SIZE: usize> IndexMut<&Andex<A, SIZE>> for AndexableArray<Andex<A, SIZE>, Item, SIZE>

source§

fn index_mut(&mut self, index: &Andex<A, SIZE>) -> &mut Item

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

impl<A, Item, const SIZE: usize> IndexMut<Andex<A, SIZE>> for AndexableArray<Andex<A, SIZE>, Item, SIZE>

source§

fn index_mut(&mut self, index: Andex<A, SIZE>) -> &mut Item

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

impl<'a, A, Item, const SIZE: usize> IntoIterator for &'a AndexableArray<A, Item, SIZE>

§

type Item = &'a Item

The type of the elements being iterated over.
§

type IntoIter = Iter<'a, Item>

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

fn into_iter(self) -> Self::IntoIter

Creates an iterator from a value. Read more
source§

impl<'a, A, Item, const SIZE: usize> IntoIterator for &'a mut AndexableArray<A, Item, SIZE>

§

type Item = &'a mut Item

The type of the elements being iterated over.
§

type IntoIter = IterMut<'a, Item>

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

fn into_iter(self) -> Self::IntoIter

Creates an iterator from a value. Read more
source§

impl<A, Item: Copy, const SIZE: usize> Copy for AndexableArray<A, Item, SIZE>

Auto Trait Implementations§

§

impl<A, Item, const SIZE: usize> Freeze for AndexableArray<A, Item, SIZE>
where Item: Freeze,

§

impl<A, Item, const SIZE: usize> RefUnwindSafe for AndexableArray<A, Item, SIZE>
where A: RefUnwindSafe, Item: RefUnwindSafe,

§

impl<A, Item, const SIZE: usize> Send for AndexableArray<A, Item, SIZE>
where A: Send, Item: Send,

§

impl<A, Item, const SIZE: usize> Sync for AndexableArray<A, Item, SIZE>
where A: Sync, Item: Sync,

§

impl<A, Item, const SIZE: usize> Unpin for AndexableArray<A, Item, SIZE>
where A: Unpin, Item: Unpin,

§

impl<A, Item, const SIZE: usize> UnwindSafe for AndexableArray<A, Item, SIZE>
where A: UnwindSafe, Item: 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<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,

§

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>,

§

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>,

§

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.