Crates.io | unsized-stack |
lib.rs | unsized-stack |
version | 0.2.0 |
source | src |
created_at | 2023-07-02 07:22:38.612611 |
updated_at | 2023-07-02 23:59:12.054014 |
description | Fast heterogeneous / unsized stack |
homepage | |
repository | https://github.com/storycraft/unsized-stack/ |
max_upload_size | |
id | 905899 |
size | 35,722 |
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
Each object is correctly padded.
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]]