(first_char: &char, chars: &mut I)
| 376 | } |
| 377 | |
| 378 | fn parse_unicode_oct<I>(first_char: &char, chars: &mut I) -> Result<char, ParseUnicodeError> |
| 379 | where |
| 380 | I: Iterator<Item = (usize, char)>, |
| 381 | { |
| 382 | let mut unicode_seq: String = String::with_capacity(3); |
| 383 | unicode_seq.push(*first_char); |
| 384 | chars.take(2).for_each(|(_, c)| unicode_seq.push(c)); |
| 385 | |
| 386 | u32::from_str_radix(&unicode_seq, 8) |
| 387 | .map_err(|e| ParseUnicodeError::Oct { |
| 388 | source: e, |
| 389 | string: unicode_seq, |
| 390 | }) |
| 391 | .and_then(|u| { |
| 392 | if u <= 255 { |
| 393 | char::from_u32(u).ok_or(ParseUnicodeError::Unicode { value: u }) |
| 394 | } else { |
| 395 | Err(ParseUnicodeError::Unicode { value: u }) |
| 396 | } |
| 397 | }) |
| 398 | } |
| 399 | |
| 400 | #[cfg(test)] |
| 401 | mod tests { |
no test coverage detected