From 0ec2c46744968b5d9de9d5f292cefd131d0ae140 Mon Sep 17 00:00:00 2001 From: ConnorSkees <39542938+ConnorSkees@users.noreply.github.com> Date: Sun, 9 Feb 2020 18:28:24 -0500 Subject: [PATCH] rustfmt --- src/builtin/math.rs | 2 +- src/lexer.rs | 2 +- src/value/ops.rs | 35 ++++++++++++++++++++--------------- 3 files changed, 22 insertions(+), 17 deletions(-) diff --git a/src/builtin/math.rs b/src/builtin/math.rs index b9a1ec7..6d7d122 100644 --- a/src/builtin/math.rs +++ b/src/builtin/math.rs @@ -30,4 +30,4 @@ pub(crate) fn register(f: &mut BTreeMap) { _ => todo!("expected number in builtin function `floor()`") } }); -} \ No newline at end of file +} diff --git a/src/lexer.rs b/src/lexer.rs index f256c13..2b7756f 100644 --- a/src/lexer.rs +++ b/src/lexer.rs @@ -60,7 +60,7 @@ impl<'a> Iterator for Lexer<'a> { TokenKind::Ident(s) } _ => unsafe { std::hint::unreachable_unchecked() }, - } + }, _ => TokenKind::Symbol(Symbol::Minus), } } diff --git a/src/value/ops.rs b/src/value/ops.rs index 49e1e3d..6ed12fd 100644 --- a/src/value/ops.rs +++ b/src/value/ops.rs @@ -1,4 +1,4 @@ -use std::ops::{Add, Sub, Mul, Div}; +use std::ops::{Add, Div, Mul, Sub}; use crate::common::QuoteKind; use crate::units::Unit; @@ -97,8 +97,7 @@ impl Sub for Value { Self::Dimension(..) => todo!("investigate adding numbers and colors"), _ => Value::Ident(format!("{}-{}", c, other), QuoteKind::None), }, - Self::BinaryOp(..) - | Self::Paren(..) => self.eval(), + Self::BinaryOp(..) | Self::Paren(..) => self.eval(), Self::Ident(s1, quotes1) => match other { Self::Ident(s2, quotes2) => { let quotes1 = match quotes1 { @@ -143,7 +142,10 @@ impl Sub for Value { QuoteKind::Double | QuoteKind::Single => QuoteKind::Double, QuoteKind::None => QuoteKind::None, }; - Value::Ident(format!("{}-{}{}{}", self, quotes, s, quotes), QuoteKind::None) + Value::Ident( + format!("{}-{}{}{}", self, quotes, s, quotes), + QuoteKind::None, + ) } Self::Null => Value::Ident(format!("{}-", self), QuoteKind::None), _ => Value::Ident(format!("{}-{}", self, other), QuoteKind::None), @@ -162,9 +164,8 @@ impl Mul for Value { Self::Dimension(num2, unit2) => Value::Dimension(num - num2, unit), _ => todo!(), }, - Self::BinaryOp(..) - | Self::Paren(..) => self.eval(), - _ => todo!("incompatible mul types") + Self::BinaryOp(..) | Self::Paren(..) => self.eval(), + _ => todo!("incompatible mul types"), } } } @@ -175,11 +176,13 @@ impl Div for Value { match self { Self::Null => todo!(), Self::Dimension(num, unit) => match other { - Self::Dimension(num2, unit2) => if unit == unit2 { - Value::Dimension(num / num2, Unit::None) - } else { - todo!("unit conversions") - }, + Self::Dimension(num2, unit2) => { + if unit == unit2 { + Value::Dimension(num / num2, Unit::None) + } else { + todo!("unit conversions") + } + } _ => todo!(), }, // Self::List(..) => todo!(), @@ -195,8 +198,7 @@ impl Div for Value { Self::Dimension(..) => todo!("investigate adding numbers and colors"), _ => Value::Ident(format!("{}/{}", c, other), QuoteKind::None), }, - Self::BinaryOp(..) - | Self::Paren(..) => self.eval(), + Self::BinaryOp(..) | Self::Paren(..) => self.eval(), Self::Ident(s1, quotes1) => match other { Self::Ident(s2, quotes2) => { let quotes1 = match quotes1 { @@ -241,7 +243,10 @@ impl Div for Value { QuoteKind::Double | QuoteKind::Single => QuoteKind::Double, QuoteKind::None => QuoteKind::None, }; - Value::Ident(format!("{}/{}{}{}", self, quotes, s, quotes), QuoteKind::None) + Value::Ident( + format!("{}/{}{}{}", self, quotes, s, quotes), + QuoteKind::None, + ) } Self::Null => Value::Ident(format!("{}/", self), QuoteKind::None), _ => Value::Ident(format!("{}/{}", self, other), QuoteKind::None),