Struct Array

Source
#[repr(C)]
pub struct Array<T> { pub index: u32, pub len: u32, /* private fields */ }
Expand description

A pointer to contiguous T elements in a slab.

use crabslab::{Array, CpuSlab, GrowableSlab, Id, Slab, SlabItem};

let ints = [1, 2, 3, 4, 5u32];
let mut slab = CpuSlab::new(vec![]);
let array = slab.append_array(&ints);
for (i, id) in array.iter().enumerate() {
    let value = slab.read(id);
    assert_eq!(ints[i], value);
}

Fields§

§index: u32§len: u32

Implementations§

Source§

impl<T> Array<T>

Source

pub const NONE: Self

Source

pub const fn new(index: u32, len: u32) -> Self

Source

pub fn len(&self) -> usize

Source

pub fn is_empty(&self) -> bool

Source

pub fn is_null(&self) -> bool

Source

pub fn contains_index(&self, index: usize) -> bool

Source

pub fn at(&self, index: usize) -> Id<T>
where T: SlabItem,

Source

pub fn starting_index(&self) -> usize

Source

pub fn iter(&self) -> ArrayIter<T>

Source

pub fn into_u32_array(self) -> Array<u32>
where T: SlabItem,

Convert this array into a u32 array.

Source

pub fn sub_slab<'a>(&'a self, slab: &'a [u32]) -> &'a [u32]
where T: SlabItem,

Return the slice of the slab that this array represents.

Source§

impl Array<u32>

Source

pub fn union(&mut self, other: &Array<u32>)

Trait Implementations§

Source§

impl<T> Clone for Array<T>

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<T> Debug for Array<T>

Source§

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

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

impl<T: SlabItem> Default for Array<T>

Source§

fn default() -> Self

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

impl<T> From<Id<T>> for Array<T>

An Id<T> is an Array<T> with a length of 1.

Source§

fn from(id: Id<T>) -> Self

Converts to this type from the input type.
Source§

impl<T> PartialEq for Array<T>

Source§

fn eq(&self, other: &Self) -> 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: SlabItem> SlabItem for Array<T>

Source§

const SLAB_SIZE: usize = 2usize

The number of u32s this type occupies in a slab of &[u32].
Source§

fn write_slab(&self, index: usize, slab: &mut [u32]) -> usize

Write the type into the slab at starting index and return the new index. Read more
Source§

fn read_slab(index: usize, slab: &[u32]) -> Self

Read the type out of the slab at index.
Source§

impl<T> Copy for Array<T>

Auto Trait Implementations§

§

impl<T> Freeze for Array<T>

§

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

§

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

§

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

§

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

§

impl<T> UnwindSafe for Array<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> 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> 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.