Crate dungeon_cell

Crate dungeon_cell 

Source
Expand description

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

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

§Example
use dungeon_cell::{DungeonCore, layout_for};

// a default DungeonCore can store any 'static type that fits in the layout
let mut core = DungeonCore::<layout_for!(String)>::default();

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

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

// lets get adventurous and store a String
core.store(String::from("hello world"));
assert_eq!(core.take(), Some(String::from("hello world")));

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

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

§Features

  • "alloc" - Enable support for alloc types.
  • "std" - Enable support for std types. Also enables "alloc".
  • "unsize" - Enable use of the nightly feature unsize. Requires a nightly compiler.
  • "many_arg_fn" - Enable implementations for functions with 11-30 arguments.

§No-std Support

This crate is #![no_std] by default, it can be used anywhere Rust can.

§Minimum Supported Rust Version

Requires Rust 1.64.0.

This crate follows the “Latest stable Rust” policy. The listed MSRV won’t be changed unless needed. However, updating the MSRV anywhere up to the latest stable at time of release is allowed.

Modules§

align
Alignment forcing wrappers.
bound
Type encoded dynamic trait bounds.
buffer
Raw byte buffer to store other type’s values.
compile_time
Compile time utilities.
layout
Compile time layout description.
lifetime_type_id
TypeId for types with a lifetime.
marker_traits
Markers for generic configuration types.
vtable
Virtual method tables.

Macros§

give_opaque_static_form
Wrap opaque typed value to implement StaticForm.
has_static_form
Implement StaticForm for type.
layout_for
Calculate the Layout needed to store a set of types.

Structs§

DungeonCore
Core of a dungeon type.

Traits§

Cleanup
Trait implemented on layouts that can be cleaned up be a vtable.

Type Aliases§

DefaultVtable
The default vtable implementation.