Ecosyste.ms: Awesome

An open API service indexing awesome lists of open source software.

Awesome Lists | Featured Topics | Projects

https://github.com/wafflelapkin/takecell

A cell type which value can only be taken once
https://github.com/wafflelapkin/takecell

Last synced: 6 days ago
JSON representation

A cell type which value can only be taken once

Awesome Lists containing this project

README

        

# takecell

[![lib.rs](https://img.shields.io/badge/lib.rs-%20-8844ff)](https://lib.rs/crates/takecell)
[![docs](https://docs.rs/takecell/badge.svg)](https://docs.rs/takecell)

`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:

```rust,ignore
impl TakeCell {
const fn new(v: T) -> Self { ... }
}
impl TakeCell {
fn take(&self) -> Option<&mut T> { ... }
}

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

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

```toml
[dependencies]
takecell = "0.1"
```