Created
July 15, 2019 15:07
-
-
Save kali/c13b31f735c15f1b36eca1e8093aab8c to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
pub fn integer<'a>(bin: bool) -> impl Fn(&'a [u8]) -> IResult<&'a [u8], i32> { | |
map(pair( | |
cond(bin, be_i32), | |
cond(!bin, | |
map_res( | |
map_res( | |
recognize(pair(opt(tag("-")), take_while(nom::character::is_digit))), | |
std::str::from_utf8, | |
), | |
|s| s.parse::<i32>(), | |
) | |
)), |(a,b)| a.or(b).unwrap()) | |
} | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment