larc

Crates.iolarc
lib.rslarc
version0.5.0
sourcesrc
created_at2023-09-18 20:06:19.422874
updated_at2023-10-31 22:39:06.736855
descriptionLazy Arc/Weak pointers
homepage
repositoryhttps://git.pipapo.org/cehteh/larc.git
max_upload_size
id976214
size19,304
(cehteh)

documentation

README

LArc Library

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.

Usage

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.

Contributing

Contributions are welcome! If you have any suggestions, bug reports, or enhancements, feel free to open an issue or create a pull request.

Status

So far this crate is useable, missing features will be added on demand/PR.

Planned

  • Add more Arc compatibilty, but leave out functions that makes little sense for our use-cases.

  • More tests and docs.

Testing

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)

Commit count: 0

cargo fmt