pub fn string_to_bool(a: String) -> bool
Expand description
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
a
- AnyString
§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));