style: Rustfmt recent changes to calc.rs

Differential Revision: https://phabricator.services.mozilla.com/D172339
This commit is contained in:
Emilio Cobos Álvarez 2023-03-13 11:33:23 +00:00 committed by Martin Robinson
parent 2c986f0005
commit 23d6ecfc57
2 changed files with 19 additions and 15 deletions

View file

@ -545,7 +545,7 @@ impl<L: CalcNodeLeaf> CalcNode<L> {
result = result + child.resolve_internal(leaf_to_output_fn)?.powi(2); result = result + child.resolve_internal(leaf_to_output_fn)?.powi(2);
} }
result.sqrt() result.sqrt()
} },
}) })
} }
@ -669,7 +669,9 @@ impl<L: CalcNodeLeaf> CalcNode<L> {
dividend.visit_depth_first_internal(f); dividend.visit_depth_first_internal(f);
divisor.visit_depth_first_internal(f); divisor.visit_depth_first_internal(f);
}, },
Self::Sum(ref mut children) | Self::MinMax(ref mut children, _) | Self::Hypot(ref mut children) => { Self::Sum(ref mut children) |
Self::MinMax(ref mut children, _) |
Self::Hypot(ref mut children) => {
for child in &mut **children { for child in &mut **children {
child.visit_depth_first_internal(f); child.visit_depth_first_internal(f);
} }
@ -1002,7 +1004,7 @@ impl<L: CalcNodeLeaf> CalcNode<L> {
}; };
replace_self_with!(&mut result); replace_self_with!(&mut result);
} },
Self::Leaf(ref mut l) => { Self::Leaf(ref mut l) => {
l.simplify(); l.simplify();
}, },

View file

@ -672,10 +672,12 @@ impl CalcNode {
}, },
MathFunction::Log => { MathFunction::Log => {
let a = Self::parse_number_argument(context, input)?; let a = Self::parse_number_argument(context, input)?;
let b = input.try_parse(|input| { let b = input
input.expect_comma()?; .try_parse(|input| {
Self::parse_number_argument(context, input) input.expect_comma()?;
}).ok(); Self::parse_number_argument(context, input)
})
.ok();
let number = match b { let number = match b {
Some(b) => a.log(b), Some(b) => a.log(b),
@ -823,8 +825,7 @@ impl CalcNode {
where where
F: FnOnce() -> Result<CSSFloat, ()>, F: FnOnce() -> Result<CSSFloat, ()>,
{ {
closure() closure().map_err(|()| input.new_custom_error(StyleParseErrorKind::UnspecifiedError))
.map_err(|()| input.new_custom_error(StyleParseErrorKind::UnspecifiedError))
} }
/// Tries to simplify this expression into a `<length>` or `<percentage>` /// Tries to simplify this expression into a `<length>` or `<percentage>`
@ -854,18 +855,19 @@ impl CalcNode {
} }
/// Tries to simplify this expression into a `<time>` value. /// Tries to simplify this expression into a `<time>` value.
fn to_time( fn to_time(&self, clamping_mode: Option<AllowedNumericType>) -> Result<Time, ()> {
&self,
clamping_mode: Option<AllowedNumericType>
) -> Result<Time, ()> {
let seconds = self.resolve(|leaf| match *leaf { let seconds = self.resolve(|leaf| match *leaf {
Leaf::Time(ref time) => Ok(time.seconds()), Leaf::Time(ref time) => Ok(time.seconds()),
_ => Err(()), _ => Err(()),
})?; })?;
Ok(Time::from_seconds_with_calc_clamping_mode( Ok(Time::from_seconds_with_calc_clamping_mode(
if nan_inf_enabled() { seconds } else { crate::values::normalize(seconds) }, if nan_inf_enabled() {
clamping_mode seconds
} else {
crate::values::normalize(seconds)
},
clamping_mode,
)) ))
} }