4 releases (2 breaking)
new 0.2.1 | Feb 12, 2025 |
---|---|
0.2.0 | Feb 6, 2025 |
0.1.0 | Dec 22, 2024 |
0.0.0 | Dec 13, 2024 |
#949 in Data structures
188 downloads per month
160KB
3K
SLoC
DynList
A linked list that can hold dynamically-sized types.
GitHub | docs.rs (latest) | crates.io (latest) | lib.rs
use core::fmt::Debug;
use dyn_list::DynList;
let mut list = DynList::<dyn Debug>::new();
list.push_back_unsize("Hello, World");
list.push_back_unsize(0);
list.push_back_unsize([1, 2, 3, 4]);
println!("{list:?}"); // ["Hello, World!", 0, [1, 2, 3, 4]]
This crate currently only works on the nightly channel.
How Does it Work?
Each node has a header, containing pointers to the previous and next nodes as well as metadata for the data.
This uses the dynode
library, which provides a framework for working with the nodes.
For Sized
types, this works exactly like a regular linked list.
Features
alloc
- Adds features that require thealloc
crate. This includes operations specific to theGlobal
allocator and sets it as the default allocator in generics.std
(requiresalloc
, default) - Adds features that require thestd
crate. Currently, this adds nothing, but disabling it enables theno_std
attribute.
TODO
This library is still in development and breaking changes may occur.
- Comment
unsafe
blocks. - Add tests.
License
The dynode
project, including DynList
, is dual-licensed under either the Apache License Version 2.0 or MIT license at your option.