From 7c451e333e6e50ae9a8c94c1882a0be0c78f3def Mon Sep 17 00:00:00 2001 From: ConnorSkees <39542938+ConnorSkees@users.noreply.github.com> Date: Sun, 16 Feb 2020 11:47:15 -0500 Subject: [PATCH] Arg errors for (de)saturate --- src/builtin/color/hsl.rs | 10 ++++------ 1 file changed, 4 insertions(+), 6 deletions(-) diff --git a/src/builtin/color/hsl.rs b/src/builtin/color/hsl.rs index 5aa18a5..98f4c09 100644 --- a/src/builtin/color/hsl.rs +++ b/src/builtin/color/hsl.rs @@ -107,9 +107,8 @@ pub(crate) fn register(f: &mut BTreeMap) { v => return Err(format!("$color: {} is not a color.", v).into()), }; let amount = match arg!(args, 1, "amount").eval() { - Value::Dimension(n, Unit::None) => n, - Value::Dimension(n, Unit::Percent) => n / Number::from(100), - _ => todo!("expected either unitless or % number for amount"), + Value::Dimension(n, _) => n / Number::from(100), + v => return Err(format!("$amount: {} is not a number.", v).into()) }; Ok(Value::Color(color.saturate(amount))) }); @@ -119,9 +118,8 @@ pub(crate) fn register(f: &mut BTreeMap) { v => return Err(format!("$color: {} is not a color.", v).into()), }; let amount = match arg!(args, 1, "amount").eval() { - Value::Dimension(n, Unit::None) => n, - Value::Dimension(n, Unit::Percent) => n / Number::from(100), - _ => todo!("expected either unitless or % number for amount"), + Value::Dimension(n, _) => n / Number::from(100), + v => return Err(format!("$amount: {} is not a number.", v).into()) }; Ok(Value::Color(color.desaturate(amount))) });