choose-from

Crates.iochoose-from
lib.rschoose-from
version0.1.1
sourcesrc
created_at2024-10-20 18:15:01.731005
updated_at2024-11-02 01:53:40.712497
descriptionSimple dependency-free crate for enforcing a selection from set values
homepage
repositoryhttps://github.com/xa888s/choose-from
max_upload_size
id1416442
size20,551
Brandon (xa888s)

documentation

https://docs.rs/choose-from

README

Choose-from

Documentation

Simple Rust library for enforcing values are chosen from a set of values, using const generics, lifetimes, and more. Please see the docs for more information.

Example usage:

use choose_from::select_from_fixed;
let choices = ["Hi", "how", "are ya?"];

let chosen = select_from_fixed(choices).with(|[first, second, third]| {
    // the provided choices allow inspection of the values
    assert_eq!(*first, "Hi");
    
    // this is our selection
    [first, third]
});

assert_eq!(chosen, ["Hi", "are ya?"]);
Commit count: 6

cargo fmt