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 flexible 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:
toml
[dependencies]
larc = "0.1.0"
Then, import and use the LArc
and LWeak
types as needed in your Rust code:
```rust use std::sync::Arc; use larc::{LArc, LWeak};
fn main() { // Create an LArc with a static reference let larc_static = LArc::from("Hello, I'm a static reference!");
// Create an LArc with an Arc reference
let larc_arc = LArc::from(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 minimal useable, missing features will be added on demand/PR.
Arc
compatibilty, but leave out functions that makes little sense for our
use-cases.