(p: &mut Parser<'a, I>)
| 13 | |
| 14 | impl<'a, T: Parse<'a> + ToNumberValue> Parse<'a> for NonNegative<T> { |
| 15 | fn parse<I>(p: &mut Parser<'a, I>) -> Result<Self> |
| 16 | where |
| 17 | I: Iterator<Item = Cursor> + Clone, |
| 18 | { |
| 19 | let cursor = p.peek_n(1); |
| 20 | let value = p.parse::<T>()?; |
| 21 | if let Some(num) = value.to_number_value() |
| 22 | && num < 0.0 |
| 23 | { |
| 24 | Err(Diagnostic::new(cursor, Diagnostic::non_negative))?; |
| 25 | } |
| 26 | |
| 27 | Ok(Self(value)) |
| 28 | } |
| 29 | } |
| 30 | |
| 31 | impl<T> NonNegative<T> { |
nothing calls this directly
no test coverage detected