fn parse_signed<T>(&mut self) -> Result<T>
    where
        T: Neg<Output = T> + AddAssign<T> + MulAssign<T> + From<i8>,
    {
        if self.next_char()? != 'i' {
            return Err(Error::ExpectedInteger);
        }
        let mut negative = false;
        if self.peek_char()? == '-' {
            negative = true;
            self.input = &self.input[1..];
        }
        let mut int = T::from(0);
        loop {
            match self.input.chars().next() {
                Some(ch @ '0'..='9') => {
                    self.input = &self.input[1..];
                    int *= T::from(10);
                    int += T::from(ch as i8 - b'0' as i8);
                }
                Some('e') => {
                    self.input = &self.input[1..];
                    if negative {
                        return Ok(int.neg());
                    } else {
                        return Ok(int);
                    }
                }
                _ => {
                    return Err(Error::ExpectedInteger);
                }
            }
        }
    }
/// Parse a possible minus sign in front of an integer.
/// Because in `1code` we have `-` sign between `i` and `e` it's easier to copy
/// `parse_unsigned`.
Parse a possible minus sign in front of an integer.
Parse a possible minus sign in front of an integer .
fn parse_signed<T>(&mut self) -> Result<T>
    where
        T: Neg<Output = T> + AddAssign<T> + MulAssign<T> + From<i8>,
    {
        if self.next_char()? != 'i' {
            return Err(Error::ExpectedInteger);
        }
        let mut negative = false;
        if self.peek_char()? == '-' {
            negative = true;
            self.input = &self.input[1..];
        }
        let mut int = T::from(0);
        loop {
            match self.input.chars().next() {
                Some(ch @ '0'..='9') => {
                    self.input = &self.input[1..];
                    int *= T::from(10);
                    int += T::from(ch as i8 - b'0' as i8);
                }
                Some('e') => {
                    self.input = &self.input[1..];
                    if negative {
                        return Ok(int.neg());
                    } else {
                        return Ok(int);
                    }
                }
                _ => {
                    return Err(Error::ExpectedInteger);
                }
            }
        }
    }
fn parse_signed < T > ( & mut self ) -> Result < T > where T : Neg < Output = T > + AddAssign < T > + MulAssign < T > + From < i8 > , { if self . next_char ( ) ? != 'i' { return Err ( Error :: ExpectedInteger ) ; } let mut negative = false ; if self . peek_char ( ) ? == '-' { negative = true ; self . input = & self . input [ 1 .. ] ; } let mut int = T :: from ( 0 ) ; loop { match self . input . chars ( ) . next ( ) { Some ( ch @ '0' ..= '9' ) => { self . input = & self . input [ 1 .. ] ; int *= T :: from ( 10 ) ; int += T :: from ( ch as i8 - b'0' as i8 ) ; } Some ( 'e' ) => { self . input = & self . input [ 1 .. ] ; if negative { return Ok ( int . neg ( ) ) ; } else { return Ok ( int ) ; } } _ => { return Err ( Error :: ExpectedInteger ) ; } } } }
Parse a possible minus sign in front of an integer.
Parse a possible minus sign in front of an integer .
&mut self
&mut self