Crates.io | humanbool |
lib.rs | humanbool |
version | 1.3.0 |
source | src |
created_at | 2016-07-25 19:07:39.614773 |
updated_at | 2021-05-09 17:30:09.246514 |
description | Parse human-entered booleans. |
homepage | https://github.com/kevincox/humanbool.rs |
repository | https://github.com/kevincox/humanbool.rs |
max_upload_size | |
id | 5786 |
size | 3,963 |
A simple library to parse human entered booleans, especially those from environment variables.
Currently the following strings are supported:
use humanbool::parse;
assert!(parse("y") == Ok(true));
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));