Function parser_compose::utf8_str
source · pub fn utf8_str(range: RangeInclusive<u32>) -> Utf8Str
Expand description
Returns a parser that recognizes the first unicode scalar value in a string slice if its value is in the specified range
The range must be bounded on both ends. Only inclusive ranges are allowed.
use parser_compose::{Parser, utf8_str};
let msg = "a1";
let alphabetic = utf8_str(97..=122);
let (value, rest) = alphabetic.try_parse(msg.into()).unwrap();
assert_eq!(value, "a");
assert_eq!(rest.input(), "1");
let result = alphabetic.try_parse(rest);
assert!(result.is_err());