2 stable releases

Uses old Rust 2015

1.3.0 May 9, 2021
1.0.0 Jul 25, 2016
Download history 49/week @ 2023-06-07 22/week @ 2023-06-14 20/week @ 2023-06-21 7/week @ 2023-06-28 17/week @ 2023-07-05 14/week @ 2023-07-12 5/week @ 2023-07-19 5/week @ 2023-07-26 4/week @ 2023-08-02 16/week @ 2023-08-09 6/week @ 2023-08-16 17/week @ 2023-08-23 13/week @ 2023-08-30 24/week @ 2023-09-06 16/week @ 2023-09-13 47/week @ 2023-09-20

102 downloads per month

Zlib license

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

No runtime deps