2 stable releases
Uses old Rust 2015
1.3.0 | May 9, 2021 |
---|---|
1.0.0 | Jul 25, 2016 |
#74 in #human
4KB
69 lines
Human Bool (for Rust)
A simple library to parse human entered booleans, especially those from environment variables.
Currently the following strings are supported:
- 1/0
- yes/no/y/n
- true/false/t/f
- on/off
From a string
use humanbool::parse;
assert!(parse("y") == Ok(true));
From the environment.
use humanbool::*;
assert_eq!(env("ENABLE_KITTENS", "f"), Ok(false));
std::env::set_var("ENABLE_KITTENS", "1");
assert!(env("ENABLE_KITTENS", "f") == Ok(true));
assert!(env("ENABLE_TURBO", "") == Err(Error::Empty));