Lines Matching refs:bytes
3 //! This works on input bytes, however, it could be easily adapted to use
4 //! `io::Read`, or any iterator over bytes. Since floats can only include
6 //! remaining bytes properly on UTF-8 boundaries.
48 /// Find and parse sign and get remaining bytes.
50 fn parse_sign<'a>(bytes: &'a [u8]) -> (bool, &'a [u8]) {
51 match bytes.get(0) {
52 Some(&b'+') => (true, &bytes[1..]),
53 Some(&b'-') => (false, &bytes[1..]),
54 _ => (true, bytes),
103 fn ltrim_zero<'a>(bytes: &'a [u8]) -> &'a [u8] {
104 let count = bytes.iter().take_while(|&&si| si == b'0').count();
105 &bytes[count..]
110 fn rtrim_zero<'a>(bytes: &'a [u8]) -> &'a [u8] {
111 let count = bytes.iter().rev().take_while(|&&si| si == b'0').count();
112 let index = bytes.len() - count;
113 &bytes[..index]
148 /// Parse float from input bytes, returning the float and the remaining bytes.
150 /// * `bytes` - Array of bytes leading with float-data.
151 fn parse_float<'a, F>(bytes: &'a [u8]) -> (F, &'a [u8])
156 let (is_positive, bytes) = parse_sign(bytes);
166 let (integer_slc, bytes) = consume_digits(bytes);
167 let (fraction_slc, bytes) = match bytes.first() {
168 Some(&b'.') => consume_digits(&bytes[1..]),
169 _ => (&bytes[..0], bytes),
171 let (exponent, bytes) = match bytes.first() {
174 let (is_positive, bytes) = parse_sign(&bytes[1..]);
175 let (exponent, bytes) = consume_digits(bytes);
176 (parse_exponent(exponent, is_positive), bytes)
178 _ => (0, bytes),
203 (float, bytes)