#[derive(Debug, Clone, PartialEq, Eq, PartialOrd, Ord, Hash)]
pub enum SpeakAs
{
Auto,
Bullets,
Numbers,
Words,
SpellOut,
Other(CounterStyleIdent),
}
impl ToCss for SpeakAs
{
fn to_css<W: fmt::Write>(&self, dest: &mut W) -> fmt::Result
{
use self::SpeakAs::*;
match *self
{
Auto => dest.write_str("auto"),
Bullets => dest.write_str("bullets"),
Numbers => dest.write_str("numbers"),
Words => dest.write_str("words"),
SpellOut => dest.write_str("spell-out"),
Other(ref ident) => ident.to_css(dest),
}
}
}
impl Parse for SpeakAs
{
fn parse<'i, 't>(_context: &ParserContext, input: &mut Parser<'i, 't>) -> Result<Self, ParseError<'i, CustomParseError<'i>>>
{
use self::SpeakAs::*;
let result = input.try(|input|
{
let ident = input.expect_ident().map_err(|_| ())?;
match_ignore_ascii_case!
{
&*ident,
"auto" => Ok(Auto),
"bullets" => Ok(Bullets),
"numbers" => Ok(Numbers),
"words" => Ok(Words),
"spell-out" => Ok(SpellOut),
_ => Err(()),
}
});
result.or_else(|_|
{
Ok(Other(CounterStyleIdent::parse(input)?))
})
}
}