Add `number` parser.
This commit is contained in:
parent
f6278a6da0
commit
a327db7285
|
@ -4,6 +4,7 @@ use abnf_core::streaming::{is_ALPHA, is_DIGIT};
|
||||||
use nom::{
|
use nom::{
|
||||||
branch::alt,
|
branch::alt,
|
||||||
bytes::streaming::{tag, take_while},
|
bytes::streaming::{tag, take_while},
|
||||||
|
character::streaming::digit1,
|
||||||
combinator::{map_res, opt, recognize},
|
combinator::{map_res, opt, recognize},
|
||||||
sequence::tuple,
|
sequence::tuple,
|
||||||
IResult,
|
IResult,
|
||||||
|
@ -35,3 +36,7 @@ pub fn base64(input: &[u8]) -> IResult<&[u8], &str> {
|
||||||
|
|
||||||
Ok((remaining, base64))
|
Ok((remaining, base64))
|
||||||
}
|
}
|
||||||
|
|
||||||
|
pub fn number(input: &[u8]) -> IResult<&[u8], u32> {
|
||||||
|
map_res(map_res(digit1, from_utf8), str::parse::<u32>)(input) // FIXME(perf): use from_utf8_unchecked
|
||||||
|
}
|
||||||
|
|
Loading…
Reference in New Issue