| Crates.io | multiref |
| lib.rs | multiref |
| version | 0.1.2 |
| created_at | 2020-07-07 13:07:09.664148+00 |
| updated_at | 2020-10-27 15:58:57.974411+00 |
| description | Multireferences: a safe way to do [&T] -> &[T] |
| homepage | |
| repository | https://github.com/arbrk1/multiref/ |
| max_upload_size | |
| id | 262275 |
| size | 17,283 |
Allowing to pass from [&T] to (an analogue of) &[T] safely
without copying anything.
This crate provides two helper types Slice and Pair
that allow the following conversions:
&'a [&'x T] -> &'a Slice<T> (and a mutable equivalent)&'a (&'x A, &'x B) -> &'a Pair<A, B> (and a mutable equivalent)&'a Slice<T> -> &'a [&'a T] (and a mutable equivalent)&'a Pair<A, B> -> &'a (&'a A, &'a B) (and a mutable equivalent)To move lifetimes from the depths of a type expression closer to its head.
Such a manipulation can be useful in a cps-heavy code.
Simply include
multiref = "0.1"
in your Cargo.toml.
The crate doesn't use any of the std library and has
the #![no_std] attribute.
There is a similiarly named crate
multi_mut.
It allows to extract multiple nonintersecting mutable references
from the std::collections maps.
However it has nothing to do with the distributive laws.
0.1.2: fixed a soundness issue with pairs0.1.1: modify methods for pairs and “slices”.0.1.0: Initial version.