From f63b254367422273de217948bb9f0c32ae7dbe2b Mon Sep 17 00:00:00 2001 From: Connor Skees <39542938+connorskees@users.noreply.github.com> Date: Mon, 27 Jul 2020 15:30:57 -0400 Subject: [PATCH] refactor `math.acos` implementation Co-authored-by: Ivan Tham --- src/builtin/modules/math.rs | 16 +++++++++------- 1 file changed, 9 insertions(+), 7 deletions(-) diff --git a/src/builtin/modules/math.rs b/src/builtin/modules/math.rs index 61f4c3c..a151c80 100644 --- a/src/builtin/modules/math.rs +++ b/src/builtin/modules/math.rs @@ -250,15 +250,17 @@ fn acos(mut args: CallArgs, parser: &mut Parser<'_>) -> SassResult { let number = args.get_err(0, "number")?; Ok(match number { - Value::Dimension(Some(n), Unit::None, ..) => { + Value::Dimension(Some(n), Unit::None, ..) => Value::Dimension( if n > Number::from(1) || n < Number::from(-1) { - return Ok(Value::Dimension(None, Unit::Deg, true)); + None } else if n.is_one() { - return Ok(Value::Dimension(Some(Number::zero()), Unit::Deg, true)); - } - - Value::Dimension(n.acos(), Unit::Deg, true) - } + Some(Number::zero()) + } else { + n.acos() + }, + Unit::Deg, + true, + ), v @ Value::Dimension(Some(..), ..) => { return Err(( format!(