unsized-stack

Crates.iounsized-stack
lib.rsunsized-stack
version0.2.0
sourcesrc
created_at2023-07-02 07:22:38.612611
updated_at2023-07-02 23:59:12.054014
descriptionFast heterogeneous / unsized stack
homepage
repositoryhttps://github.com/storycraft/unsized-stack/
max_upload_size
id905899
size35,722
storycraft (storycraft)

documentation

README

UnsizedStack

Store unboxed DST objects

Provides efficient list when the elements don't need to get resorted for DST types.

NOTE: UnsizedStack relies on an unspecified fat pointer representation

Diagram

diagram

Each object is correctly padded.

Example

Trait object

use unsized_stack::UnsizedStack;
use std::fmt::Debug;

let mut stack = UnsizedStack::<dyn Debug>::new();
stack.push("str", |item| item as _);
stack.push(1, |item| item as _);
stack.push(28342.2, |item| item as _);
dbg!(stack); // Print stack = ["str", 1, 28342.2]

str

use unsized_stack::UnsizedStack;
use std::fmt::Debug;

let mut stack = UnsizedStack::<str>::new();
stack.push("str", |item| item as _);
stack.push("asdf", |item| item as _);
stack.push("abcd", |item| item as _);
dbg!(stack); // Print stack = ["str", "asdf", "abcd"]

slices

use unsized_stack::UnsizedStack;
use std::fmt::Debug;

let mut stack = UnsizedStack::<[i32]>::new();
stack.push([1, 2], |item| item as _);
stack.push([3, 4], |item| item as _);
stack.push([5, 6], |item| item as _);
dbg!(stack); // Print stack = [[1, 2], [3, 4], [5, 6]]
Commit count: 24

cargo fmt