ref_kind

Crate Docs License

Different reference kinds in Rust.

Provides 2 kinds of reference: immutable and mutable. All of them represented in one enum RefKind, which allows you to store immutable and mutable references together.

In addition, this crate contains RefKindMap which is a HashMap of reference kinds. This structure can easily be created from HashMap iterator (immutable or mutable one):

```rust use std::collections::HashMap; use ref_kind::RefKindMap;

let mut map = HashMap::new(); map.insert("Hello World", 0); map.insert("The Answer to the Ultimate Question of Life, the Universe, and Everything", 42);

let mut refs = map.iter_mut().map(|(&k, v)| (k, v)).collect::>(); ```

Then it can be used to retrieve multiple mutable references from the HashMap:

```rust let hello = refs.movemut("Hello World").unwrap(); let answer = refs.movemut("The Answer to the Ultimate Question of Life, the Universe, and Everything").unwrap();

asserteq!(*hello, 0); asserteq!(*answer, 42); ```

This crate used to be the part of toucan_ecs crate, but now was moved into the separate crate!

#![no_std] support

This crate is a no_std crate. It depends only on the alloc and core crates.

#![forbid(unsafe_code)]

This crate contains no unsafe code.

Flags

This crate has the following Cargo features:

| Feature name | Description | |--------------|-------------------------------------------------------------------| | bumpalo | Compatibility with bumpalo crate to be able to reuse heap space |

License

Licensed under either of

at your option.