(text: &Wtf8)
| 285 | } |
| 286 | |
| 287 | fn parse_precision(text: &Wtf8) -> Result<(Option<usize>, &Wtf8), FormatSpecError> { |
| 288 | let mut chars = text.code_points(); |
| 289 | Ok(match chars.next().and_then(CodePoint::to_char) { |
| 290 | Some('.') => { |
| 291 | let (size, remaining) = parse_number(chars.as_wtf8())?; |
| 292 | if let Some(size) = size { |
| 293 | if size > i32::MAX as usize { |
| 294 | return Err(FormatSpecError::PrecisionTooBig); |
| 295 | } |
| 296 | (Some(size), remaining) |
| 297 | } else { |
| 298 | (None, text) |
| 299 | } |
| 300 | } |
| 301 | _ => (None, text), |
| 302 | }) |
| 303 | } |
| 304 | |
| 305 | impl FormatSpec { |
| 306 | pub fn parse(text: impl AsRef<Wtf8>) -> Result<Self, FormatSpecError> { |
no test coverage detected