takecell

Crates.iotakecell
lib.rstakecell
version0.1.1
sourcesrc
created_at2021-10-31 16:22:03.964829
updated_at2022-01-23 17:25:05.655843
descriptionA cell type which value can only be taken once
homepage
repositoryhttps://github.com/wafflelapkin/takecell
max_upload_size
id474786
size23,866
Waffle Maybe (WaffleLapkin)

documentation

https://docs.rs/takecell

README

takecell

lib.rs docs

takecell provides two new cell-like types, TakeCell and TakeOwnCell. Both may store arbitrary non-Copy types, can be read from at most once and provide direct unique access to the stored contents. The core API looks roughly like this:

impl<T> TakeCell<T> {
    const fn new(v: T) -> Self { ... }
}
impl<T: ?Sized> TakeCell<T> {
    fn take(&self) -> Option<&mut T> { ... }
}

impl<T> TakeOwnCell<T> {
    const fn new(v: T) -> Self { ... }
    fn take(&self) -> Option<T> { ... }
}

To use this crate add the following to your Cargo.toml:

[dependencies] 
takecell = "0.1"
Commit count: 21

cargo fmt