2 stable releases

Uses old Rust 2015

1.3.0 May 9, 2021
1.0.0 Jul 25, 2016

#37 in #env-variables

Download history 81/week @ 2024-03-29 12/week @ 2024-04-05 7/week @ 2024-05-10

79 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