Crates.io | larc |
lib.rs | larc |
version | 0.5.0 |
source | src |
created_at | 2023-09-18 20:06:19.422874 |
updated_at | 2023-10-31 22:39:06.736855 |
description | Lazy Arc/Weak pointers |
homepage | |
repository | https://git.pipapo.org/cehteh/larc.git |
max_upload_size | |
id | 976214 |
size | 19,304 |
LArc is a Rust crate that implements a flexible smart pointer, LArc
and LWeak
, capable of storing
either static or lifetime annotated references or reference-counted smart pointers (Arc
).
The LArc Library provides a smart pointer, LArc, capable of seamlessly handling both static and dynamically allocated data. This duality allows for efficient management of data and structures that may transition between static and dynamic states. Common use cases include managing configuration data, resources, and caching, where data can start as static and later become dynamically updated.
To use this library in your Rust project, simply add it as a dependency in your Cargo.toml
file:
[dependencies]
larc = "0.5.0"
Then, import and use the LArc
and LWeak
types as needed in your Rust code:
use std::sync::Arc;
use larc::{LArc, LWeak};
fn main() {
// Create an LArc with a static reference
let larc_static = LArc::from_static("Hello, I'm a static reference!");
// Create an LArc with an Arc reference
let larc_arc = LArc::from_arc(Arc::<str>::from("Hello, I'm an Arc reference!"));
// Downgrade LArc to LWeak
let lweak = LArc::downgrade(&larc_arc);
}
For more information on the usage and API, refer to the documentation.
Contributions are welcome! If you have any suggestions, bug reports, or enhancements, feel free to open an issue or create a pull request.
So far this crate is useable, missing features will be added on demand/PR.
Add more Arc
compatibilty, but leave out functions that makes little sense for our
use-cases.
More tests and docs.
The test-suite is far from complete yet, eventually cargo-mutants should be used to get good coverage of all cases.
Note that by design 'make_static()' intentionally leaks memory. Thus test that leak memory are disabled under miri. (This should be feature gated with MIRIFLAGS=-Zmiri-ignore-leaks)