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

pub fn string_to_bool(a: String) -> bool

Parse String 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 String.

Arguments

Examples

use rustils::parse::boolean::string_to_bool;

let a = String::from("true");
let b = String::from("y");
let c = String::from("0");

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