style: Some trivial cleanup.

This commit is contained in:
Emilio Cobos Álvarez 2017-12-24 19:21:10 +01:00
parent 6eb0143541
commit a491ccac83
No known key found for this signature in database
GPG key ID: 056B727BB9C1027C
3 changed files with 17 additions and 20 deletions

View file

@ -401,11 +401,10 @@ pub enum Symbol {
impl Parse for Symbol { impl Parse for Symbol {
fn parse<'i, 't>(_context: &ParserContext, input: &mut Parser<'i, 't>) -> Result<Self, ParseError<'i>> { fn parse<'i, 't>(_context: &ParserContext, input: &mut Parser<'i, 't>) -> Result<Self, ParseError<'i>> {
let location = input.current_source_location(); let location = input.current_source_location();
match input.next() { match *input.next()? {
Ok(&Token::QuotedString(ref s)) => Ok(Symbol::String(s.as_ref().to_owned())), Token::QuotedString(ref s) => Ok(Symbol::String(s.as_ref().to_owned())),
Ok(&Token::Ident(ref s)) => Ok(Symbol::Ident(s.as_ref().to_owned())), Token::Ident(ref s) => Ok(Symbol::Ident(s.as_ref().to_owned())),
Ok(t) => Err(location.new_unexpected_token_error(t.clone())), ref t => Err(location.new_unexpected_token_error(t.clone())),
Err(e) => Err(e.into()),
} }
} }
} }
@ -470,11 +469,10 @@ impl Parse for Ranges {
fn parse_bound<'i, 't>(input: &mut Parser<'i, 't>) -> Result<Option<i32>, ParseError<'i>> { fn parse_bound<'i, 't>(input: &mut Parser<'i, 't>) -> Result<Option<i32>, ParseError<'i>> {
let location = input.current_source_location(); let location = input.current_source_location();
match input.next() { match *input.next()? {
Ok(&Token::Number { int_value: Some(v), .. }) => Ok(Some(v)), Token::Number { int_value: Some(v), .. } => Ok(Some(v)),
Ok(&Token::Ident(ref ident)) if ident.eq_ignore_ascii_case("infinite") => Ok(None), Token::Ident(ref ident) if ident.eq_ignore_ascii_case("infinite") => Ok(None),
Ok(t) => Err(location.new_unexpected_token_error(t.clone())), ref t => Err(location.new_unexpected_token_error(t.clone())),
Err(e) => Err(e.into()),
} }
} }

View file

@ -101,11 +101,11 @@ macro_rules! parse_quoted_or_unquoted_string {
let start = input.position(); let start = input.position();
input.parse_entirely(|input| { input.parse_entirely(|input| {
let location = input.current_source_location(); let location = input.current_source_location();
match input.next() { match *input.next()? {
Ok(&Token::QuotedString(ref value)) => Token::QuotedString(ref value) => {
Ok($url_matching_function(value.as_ref().to_owned())), Ok($url_matching_function(value.as_ref().to_owned()))
Ok(t) => Err(location.new_unexpected_token_error(t.clone())), },
Err(e) => Err(e.into()), ref t => Err(location.new_unexpected_token_error(t.clone())),
} }
}).or_else(|_: ParseError| { }).or_else(|_: ParseError| {
while let Ok(_) = input.next() {} while let Ok(_) = input.next() {}

View file

@ -171,11 +171,10 @@ impl hash::Hash for KeyframesName {
impl Parse for KeyframesName { impl Parse for KeyframesName {
fn parse<'i, 't>(_context: &ParserContext, input: &mut Parser<'i, 't>) -> Result<Self, ParseError<'i>> { fn parse<'i, 't>(_context: &ParserContext, input: &mut Parser<'i, 't>) -> Result<Self, ParseError<'i>> {
let location = input.current_source_location(); let location = input.current_source_location();
match input.next() { match *input.next()? {
Ok(&Token::Ident(ref s)) => Ok(KeyframesName::Ident(CustomIdent::from_ident(location, s, &["none"])?)), Token::Ident(ref s) => Ok(KeyframesName::Ident(CustomIdent::from_ident(location, s, &["none"])?)),
Ok(&Token::QuotedString(ref s)) => Ok(KeyframesName::QuotedString(Atom::from(s.as_ref()))), Token::QuotedString(ref s) => Ok(KeyframesName::QuotedString(Atom::from(s.as_ref()))),
Ok(t) => Err(location.new_unexpected_token_error(t.clone())), ref t => Err(location.new_unexpected_token_error(t.clone())),
Err(e) => Err(e.into()),
} }
} }
} }