aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorEmilio Cobos Álvarez <emilio@crisal.io>2017-12-09 20:26:09 +0100
committerEmilio Cobos Álvarez <emilio@crisal.io>2017-12-09 20:26:09 +0100
commitdbf0183b0fae56da5dcfa06a89843cff721390a3 (patch)
tree9eb6d867d5a8c02b901bf95b4a3179e3b6806bc6
parent5f4f355cea4a24992ac9efa97f4a6e1837008e0b (diff)
downloadservo-dbf0183b0fae56da5dcfa06a89843cff721390a3.tar.gz
servo-dbf0183b0fae56da5dcfa06a89843cff721390a3.zip
style: Use ? in Option more often.
-rw-r--r--components/style/properties/declaration_block.rs19
-rw-r--r--components/style/properties/properties.mako.rs17
2 files changed, 13 insertions, 23 deletions
diff --git a/components/style/properties/declaration_block.rs b/components/style/properties/declaration_block.rs
index 788d39c4b48..0341edfae82 100644
--- a/components/style/properties/declaration_block.rs
+++ b/components/style/properties/declaration_block.rs
@@ -140,14 +140,9 @@ impl<'a> Iterator for NormalDeclarationIterator<'a> {
fn next(&mut self) -> Option<Self::Item> {
loop {
- let next = self.0.iter.next();
- match next {
- Some((decl, importance)) => {
- if !importance {
- return Some(decl);
- }
- },
- None => return None,
+ let (decl, importance) = self.0.iter.next()?;
+ if !importance {
+ return Some(decl);
}
}
}
@@ -171,7 +166,7 @@ impl<'a, 'cx, 'cx_a:'cx> AnimationValueIterator<'a, 'cx, 'cx_a> {
declarations: &'a PropertyDeclarationBlock,
context: &'cx mut Context<'cx_a>,
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 {
iter: declarations.normal_declaration_iter(),
@@ -187,11 +182,7 @@ impl<'a, 'cx, 'cx_a:'cx> Iterator for AnimationValueIterator<'a, 'cx, 'cx_a> {
#[inline]
fn next(&mut self) -> Option<Self::Item> {
loop {
- let next = self.iter.next();
- let decl = match next {
- Some(decl) => decl,
- None => return None,
- };
+ let decl = self.iter.next()?;
let animation = AnimationValue::from_declaration(
decl,
diff --git a/components/style/properties/properties.mako.rs b/components/style/properties/properties.mako.rs
index 4c05a1541f4..bdabec78fe3 100644
--- a/components/style/properties/properties.mako.rs
+++ b/components/style/properties/properties.mako.rs
@@ -850,11 +850,13 @@ impl ShorthandId {
/// Finds and returns an appendable value for the given declarations.
///
/// Returns the optional appendable value.
- pub fn get_shorthand_appendable_value<'a, I>(self,
- declarations: I)
- -> Option<AppendableValue<'a, I::IntoIter>>
- where I: IntoIterator<Item=&'a PropertyDeclaration>,
- I::IntoIter: Clone,
+ pub fn get_shorthand_appendable_value<'a, I>(
+ self,
+ declarations: I,
+ ) -> Option<AppendableValue<'a, I::IntoIter>>
+ where
+ I: IntoIterator<Item=&'a PropertyDeclaration>,
+ I::IntoIter: Clone,
{
let declarations = declarations.into_iter();
@@ -862,10 +864,7 @@ impl ShorthandId {
let mut declarations2 = declarations.clone();
let mut declarations3 = declarations.clone();
- let first_declaration = match declarations2.next() {
- Some(declaration) => declaration,
- None => return None
- };
+ let first_declaration = declarations2.next()?;
// https://drafts.csswg.org/css-variables/#variables-in-shorthands
if let Some(css) = first_declaration.with_variables_from_shorthand(self) {