stack-any

Crates.iostack-any
lib.rsstack-any
version0.1.2
sourcesrc
created_at2024-06-27 13:52:46.43072
updated_at2024-06-29 11:51:13.170362
descriptionA library that provides a type that owns same size type on the stack for type erasure.
homepage
repositoryhttps://github.com/GossiperLoturot/stack-any
max_upload_size
id1285771
size9,332
Takumi Sugimoto (GossiperLoturot)

documentation

README

stack-any

crates.io doc.rs

A library that provides a type that owns same size type on the stack for type erasure.

Usage

let mut stacks = [
    stack_any::stack_any!(Vec<i32>, vec![]),
    stack_any::stack_any!(Vec<char>, vec![]),
];

stacks[0].downcast_mut::<Vec<i32>>().unwrap().push(5);
stacks[1].downcast_mut::<Vec<char>>().unwrap().push('x');

assert_eq!(stacks[0].downcast_ref(), Some(&vec![5]));
assert_eq!(stacks[1].downcast_ref(), Some(&vec!['x']));
Commit count: 4

cargo fmt