Crate dungeon_cell

source ·
Expand description

Dungeon Cell

Cell and Cell-like types that can store any static type without dynamic memory.

Currently only the core primitive is implemented (unsized, cell, stack vec, … are in progress).

Example

use dungeon_cell::{DungeonCore, layout_for};

let mut c: DungeonCore<layout_for!(i32, f64)> = DungeonCore::new();

// we can store a i32 and get it back
c.store(1234);
assert_eq!(c.take::<i32>(), Some(1234));

// we can store a f64 and get it back
c.store(1.234);
assert_eq!(c.take::<f64>(), Some(1.234));

// we can't take a type the core isn't storing
c.store(1234);
assert_eq!(c.take::<f64>(), None);

// we can borrow both unique and shared
c.store(1234);
*c.borrow_mut::<i32>().unwrap() += 10;
assert_eq!(c.borrow::<i32>(), Some(&1244));

Modules

Markers for generic configuration types.
Virtual method tables.

Macros

Calculate the Layout needed to store a set of types.

Structs

Force minimum alignment of a type.
Alignment in bytes.
Core of a dungeon type.
Flag for if a type implements std::marker::Send.
Combination of size and alignment.
Size in bytes.

Traits

Marker for if a Layout can store a given T.

Type Definitions

Opaque type with layout given by a Layout.