style: Use ? in Option more often.

This commit is contained in:
Emilio Cobos Álvarez 2017-12-09 20:26:09 +01:00
parent 5f4f355cea
commit dbf0183b0f
No known key found for this signature in database
GPG key ID: 056B727BB9C1027C
2 changed files with 13 additions and 23 deletions

View file

@ -140,14 +140,9 @@ impl<'a> Iterator for NormalDeclarationIterator<'a> {
fn next(&mut self) -> Option<Self::Item> { fn next(&mut self) -> Option<Self::Item> {
loop { loop {
let next = self.0.iter.next(); let (decl, importance) = self.0.iter.next()?;
match next { if !importance {
Some((decl, importance)) => { return Some(decl);
if !importance {
return Some(decl);
}
},
None => return None,
} }
} }
} }
@ -171,7 +166,7 @@ impl<'a, 'cx, 'cx_a:'cx> AnimationValueIterator<'a, 'cx, 'cx_a> {
declarations: &'a PropertyDeclarationBlock, declarations: &'a PropertyDeclarationBlock,
context: &'cx mut Context<'cx_a>, context: &'cx mut Context<'cx_a>,
default_values: &'a ComputedValues, default_values: &'a ComputedValues,
extra_custom_properties: Option<&'a Arc<::custom_properties::CustomPropertiesMap>>, extra_custom_properties: Option<&'a Arc<::custom_properties::CustomPropertiesMap>>,
) -> AnimationValueIterator<'a, 'cx, 'cx_a> { ) -> AnimationValueIterator<'a, 'cx, 'cx_a> {
AnimationValueIterator { AnimationValueIterator {
iter: declarations.normal_declaration_iter(), iter: declarations.normal_declaration_iter(),
@ -187,11 +182,7 @@ impl<'a, 'cx, 'cx_a:'cx> Iterator for AnimationValueIterator<'a, 'cx, 'cx_a> {
#[inline] #[inline]
fn next(&mut self) -> Option<Self::Item> { fn next(&mut self) -> Option<Self::Item> {
loop { loop {
let next = self.iter.next(); let decl = self.iter.next()?;
let decl = match next {
Some(decl) => decl,
None => return None,
};
let animation = AnimationValue::from_declaration( let animation = AnimationValue::from_declaration(
decl, decl,

View file

@ -850,11 +850,13 @@ impl ShorthandId {
/// Finds and returns an appendable value for the given declarations. /// Finds and returns an appendable value for the given declarations.
/// ///
/// Returns the optional appendable value. /// Returns the optional appendable value.
pub fn get_shorthand_appendable_value<'a, I>(self, pub fn get_shorthand_appendable_value<'a, I>(
declarations: I) self,
-> Option<AppendableValue<'a, I::IntoIter>> declarations: I,
where I: IntoIterator<Item=&'a PropertyDeclaration>, ) -> Option<AppendableValue<'a, I::IntoIter>>
I::IntoIter: Clone, where
I: IntoIterator<Item=&'a PropertyDeclaration>,
I::IntoIter: Clone,
{ {
let declarations = declarations.into_iter(); let declarations = declarations.into_iter();
@ -862,10 +864,7 @@ impl ShorthandId {
let mut declarations2 = declarations.clone(); let mut declarations2 = declarations.clone();
let mut declarations3 = declarations.clone(); let mut declarations3 = declarations.clone();
let first_declaration = match declarations2.next() { let first_declaration = declarations2.next()?;
Some(declaration) => declaration,
None => return None
};
// https://drafts.csswg.org/css-variables/#variables-in-shorthands // https://drafts.csswg.org/css-variables/#variables-in-shorthands
if let Some(css) = first_declaration.with_variables_from_shorthand(self) { if let Some(css) = first_declaration.with_variables_from_shorthand(self) {