2 stable releases

Uses old Rust 2015

1.3.0 May 9, 2021
1.0.0 Jul 25, 2016

#71 in #human

Download history 61/week @ 2023-11-27 2/week @ 2024-01-15 1/week @ 2024-02-19 38/week @ 2024-02-26 14/week @ 2024-03-04 5/week @ 2024-03-11

58 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