use crate::parser::{Parse, ParserContext};
use crate::values::generics::ratio::Ratio as GenericRatio;
use crate::values::specified::NonNegativeNumber;
use crate::One;
use cssparser::Parser;
use style_traits::ParseError;
pub type Ratio = GenericRatio<NonNegativeNumber>;
impl Parse for Ratio {
fn parse<'i, 't>(
context: &ParserContext,
input: &mut Parser<'i, 't>,
) -> Result<Self, ParseError<'i>> {
let a = NonNegativeNumber::parse(context, input)?;
let b = match input.try_parse(|input| input.expect_delim('/')) {
Ok(()) => NonNegativeNumber::parse(context, input)?,
_ => One::one(),
};
Ok(GenericRatio(a, b))
}
}