Skip to content

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

Notifications You must be signed in to change notification settings

Vi-Kitten/Choice

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

8 Commits
 
 
 
 
 
 
 
 
 
 

Repository files navigation

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),
));

About

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

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages