MCPcopy Create free account
hub / github.com/csskit/csskit / parse

Method parse

crates/css_ast/src/constraints.rs:15–28  ·  view source on GitHub ↗
(p: &mut Parser<'a, I>)

Source from the content-addressed store, hash-verified

13
14impl<'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
31impl<T> NonNegative<T> {

Callers

nothing calls this directly

Calls 4

ErrClass · 0.85
peek_nMethod · 0.80
to_number_valueMethod · 0.45
is_emptyMethod · 0.45

Tested by

no test coverage detected