pub fn parse_bool(input: &str) -> IResult<&str, bool>Expand description
Parse a boolean literal: true or false.
This parser recognizes the exact string literals "true" and "false"
(case-sensitive) as boolean values. It does not accept variations like
TRUE, True, or numeric representations.
§Arguments
input- A string slice containing the boolean literal to parse
§Returns
IResult<&str, bool>- A nom parser result containing:- Remaining input after parsing the boolean
- Parsed
boolvalue (trueorfalse)
§Examples
use aimx::parse_bool;
let (remaining, value) = parse_bool("true").unwrap();
assert_eq!(remaining, "");
assert_eq!(value, true);
let (remaining, value) = parse_bool("false and more").unwrap();
assert_eq!(remaining, " and more");
assert_eq!(value, false);§Error Handling
Returns a nom error if the input does not start with "true" or "false".
The parser is exact and does not perform case conversion or fuzzy matching.