Function chomp::ascii::signed
[−]
[src]
pub fn signed<I: Input<Token = u8>, T, F>(i: I, f: F) -> SimpleResult<I, T> where
T: Copy + ValueFrom<i8, Err = NoError> + Add<Output = T> + Mul<Output = T>,
F: FnOnce(I) -> SimpleResult<I, T>,
Parses a number with an optional leading '+' or '-'.
Note
The from i8
bound here is usually smaller than the number parser requirement for signed
integers (usually the smallest possible signed is i16
).
Example
use chomp::parse_only; use chomp::ascii::{decimal, signed}; let r: Result<i16, _> = parse_only(|i| signed(i, decimal), b"-123"); assert_eq!(r, Ok(-123i16));