Crates.io | choose-from |
lib.rs | choose-from |
version | 0.1.1 |
source | src |
created_at | 2024-10-20 18:15:01.731005 |
updated_at | 2024-11-02 01:53:40.712497 |
description | Simple dependency-free crate for enforcing a selection from set values |
homepage | |
repository | https://github.com/xa888s/choose-from |
max_upload_size | |
id | 1416442 |
size | 20,551 |
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?"]);