Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/archshift/dynstack
A stack for rust trait objects that minimizes allocations
https://github.com/archshift/dynstack
collection rust trait-object
Last synced: 28 days ago
JSON representation
A stack for rust trait objects that minimizes allocations
- Host: GitHub
- URL: https://github.com/archshift/dynstack
- Owner: archshift
- License: mit
- Created: 2018-11-05T04:10:39.000Z (about 6 years ago)
- Default Branch: master
- Last Pushed: 2022-08-10T00:00:16.000Z (over 2 years ago)
- Last Synced: 2024-10-31T11:58:17.390Z (about 1 month ago)
- Topics: collection, rust, trait-object
- Language: Rust
- Homepage:
- Size: 34.2 KB
- Stars: 126
- Watchers: 4
- Forks: 8
- Open Issues: 2
-
Metadata Files:
- Readme: README.md
- Changelog: CHANGELOG.md
- License: LICENSE
Awesome Lists containing this project
- AwesomeCppGameDev - dynstack
README
# dynstack
## A stack for trait objects that minimizes allocations
**COMPATIBILITY NOTE:** `dynstack` relies on an underspecified fat pointer representation. Though
it isn't expected to change in the foreseeable future, this crate expects Rust 1.34's representation.### Usage
`dynstack` can mostly replace anywhere you'd use a stack, or a vector that doesn't
require removal from its center.```rust
let mut stack = DynStack::::new();
dyn_push!(stack, "hello, world!");
dyn_push!(stack, 0usize);
dyn_push!(stack, [1, 2, 3, 4, 5, 6]);for item in stack.iter() {
println!("{:?}", item);
}// prints:
// "hello, world!"
// 0
// [1, 2, 3, 4, 5, 6]
```