multiref 0.1.2

Multireferences: a safe way to do [&T] -> &[T]
Documentation
  • Coverage
  • 100%
    3 out of 3 items documented3 out of 3 items with examples
  • Size
  • Source code size: 16.91 kB This is the summed size of all the files inside the crates.io package for this release.
  • Documentation size: 1.32 MB This is the summed size of all files generated by rustdoc for all configured targets
  • Ø build duration
  • this release: 8s Average build duration of successful builds.
  • all releases: 8s Average build duration of successful builds in releases after 2024-10-23.
  • Links
  • arbrk1/multiref
    1 0 0
  • crates.io
  • Dependencies
  • Versions
  • Owners
  • arbrk1

crate docs

Multireferences for Rust

Allowing to pass from [&T] to (an analogue of) &[T] safely without copying anything.

More precisely

This crate provides two helper types Slice and Pair that allow the following conversions:

The inverse distributive law

  • &'a [&'x T] -> &'a Slice<T> (and a mutable equivalent)
  • &'a (&'x A, &'x B) -> &'a Pair<A, B> (and a mutable equivalent)

The forward distributive law

  • &'a Slice<T> -> &'a [&'a T] (and a mutable equivalent)
  • &'a Pair<A, B> -> &'a (&'a A, &'a B) (and a mutable equivalent)

What for?

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.

Details

HERE

Usage

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.

Similiar crates

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.

Versions

  • 0.1.2: fixed a soundness issue with pairs
  • 0.1.1: modify methods for pairs and “slices”.
  • 0.1.0: Initial version.