Struct Table

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

A contiguous memory block.

§Example:

// Make sure that the type used in the table implements the Default trait.
#[derive(Default)]
struct Entity {
    x: f32,
    y: f32,   
}

struct Data {
    // Memory reserved for (in this specific example) 512 entities.
    entities: Table<Entity, 512>
}

Implementations§

Source§

impl<T, const N: usize> Table<T, N>
where T: Default,

Source

pub fn get(&self, i: usize) -> &T

Get a reference to an element at the given index.

Source

pub fn get_mut(&mut self, i: usize) -> &mut T

Get a mutable reference to an element at the given index.

Source

pub fn set(&mut self, i: usize, e: T)

Set an element at the given index.

Source

pub fn iter(&self) -> Iter<'_, T>

Iterate over references of the elements.

Source

pub fn iter_mut(&mut self) -> IterMut<'_, T>

Iterate over mutable references of the elements.

Source

pub fn zero(&mut self, i: usize)

Reset the element at the given index back to its default values (AKA zeroing).

Trait Implementations§

Source§

impl<T, const N: usize> Default for Table<T, N>
where T: Default,

Source§

fn default() -> Self

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

Auto Trait Implementations§

§

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

§

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

§

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

§

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

§

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

§

impl<T, const N: usize> UnwindSafe for Table<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> 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.