[][src]Function rustils::parse::boolean::str_to_bool

pub fn str_to_bool(a: &str) -> bool

Parse &str to bool

If a is "0", "f", "false", "n", "no" then returns false.
If a is "1", "t", "true", "y", "yes" then returns true.
Otherwise panic!

Panics

Panics ParseError::InvalidString if a is no valid &str.

Arguments

Examples

use rustils::parse::boolean::str_to_bool;

let a = "true";
let b = "y";
let c = "0";

assert!(str_to_bool(a));
assert!(str_to_bool(b));
assert!(!str_to_bool(c));