exclusive-choice 0.1.0

An implementation of affine addative conjunction in the rust type system.
Documentation
  • Coverage
  • 78.33%
    47 out of 60 items documented0 out of 53 items with examples
  • Size
  • Source code size: 25.97 kB This is the summed size of all the files inside the crates.io package for this release.
  • Documentation size: 11.27 MB This is the summed size of all files generated by rustdoc for all configured targets
  • Ø build duration
  • this release: 17s Average build duration of successful builds.
  • all releases: 17s Average build duration of successful builds in releases after 2024-10-23.
  • Links
  • Vi-Kitten/Choice
    0 0 0
  • crates.io
  • Dependencies
  • Versions
  • Owners
  • Vi-Kitten

Choice

An implementation of affine addative conjunction in the rust type system.

This can be used to group mutually exclusive function parameters so that they can have overlapping captures.

Usage

The following code using Result does not work as it

Ok(0)
    .map(|x: i32| sender.send(x + 1))
    .map_err(|y: i32| sender.send(y - 1));
//!          ^^^^^^^^ use of moved value: `sender`

Whereas using Either and passing a Choice of two functions circumvents this issues by storing the two branches in the same object.

Either::Left(0).choose_map(Exclusive::new(
    sender,
    |s| move |x: i32| s.send(x + 1),
    |s| move |y: i32| s.send(y - 1),
));