Parse perspective property as non negative and add tests

This commit is contained in:
n0max 2017-03-26 23:15:04 +02:00
parent c5c4354f84
commit 20c07332a1
4 changed files with 50 additions and 0 deletions

View file

@ -458,6 +458,17 @@ impl Parse for Length {
}
}
impl Either<Length, None_> {
/// Parse a non-negative length or none
#[inline]
pub fn parse_non_negative_length(context: &ParserContext, input: &mut Parser) -> Result<Self, ()> {
if input.try(|input| None_::parse(context, input)).is_ok() {
return Ok(Either::Second(None_));
}
Length::parse_non_negative(input).map(Either::First)
}
}
impl Either<Length, Normal> {
#[inline]
#[allow(missing_docs)]