Refactor unit conversions into separate file
This commit is contained in:
parent
0ad5e554b3
commit
dcb712e3d4
@ -9,7 +9,7 @@ use crate::function::Function;
|
||||
use crate::mixin::Mixin;
|
||||
use crate::scope::Scope;
|
||||
use crate::selector::Selector;
|
||||
use crate::units::Unit;
|
||||
use crate::unit::Unit;
|
||||
use crate::utils::{devour_whitespace, devour_whitespace_or_comment};
|
||||
use crate::value::{Number, Value};
|
||||
use crate::{Stmt, Token, TokenKind};
|
||||
|
@ -3,7 +3,7 @@ use std::collections::HashMap;
|
||||
use super::Builtin;
|
||||
use crate::color::Color;
|
||||
use crate::common::QuoteKind;
|
||||
use crate::units::Unit;
|
||||
use crate::unit::Unit;
|
||||
use crate::value::{Number, Value};
|
||||
|
||||
pub(crate) fn register(f: &mut HashMap<String, Builtin>) {
|
||||
|
@ -2,7 +2,7 @@ use std::collections::HashMap;
|
||||
|
||||
use super::Builtin;
|
||||
use crate::common::QuoteKind;
|
||||
use crate::units::Unit;
|
||||
use crate::unit::Unit;
|
||||
use crate::value::Number;
|
||||
use crate::value::Value;
|
||||
|
||||
|
@ -3,7 +3,7 @@ use std::collections::HashMap;
|
||||
use super::Builtin;
|
||||
use crate::color::Color;
|
||||
use crate::common::QuoteKind;
|
||||
use crate::units::Unit;
|
||||
use crate::unit::Unit;
|
||||
use crate::value::{Number, Value};
|
||||
|
||||
macro_rules! opt_rgba {
|
||||
|
@ -2,7 +2,7 @@ use std::collections::HashMap;
|
||||
|
||||
use super::Builtin;
|
||||
use crate::color::Color;
|
||||
use crate::units::Unit;
|
||||
use crate::unit::Unit;
|
||||
use crate::value::{Number, Value};
|
||||
|
||||
pub(crate) fn register(f: &mut HashMap<String, Builtin>) {
|
||||
|
@ -1,7 +1,7 @@
|
||||
use std::collections::HashMap;
|
||||
|
||||
use super::Builtin;
|
||||
use crate::units::Unit;
|
||||
use crate::unit::Unit;
|
||||
use crate::value::{Number, Value};
|
||||
|
||||
pub(crate) fn register(f: &mut HashMap<String, Builtin>) {
|
||||
|
@ -1,7 +1,7 @@
|
||||
use std::collections::HashMap;
|
||||
|
||||
use super::Builtin;
|
||||
use crate::units::Unit;
|
||||
use crate::unit::Unit;
|
||||
use crate::value::{Number, Value};
|
||||
|
||||
pub(crate) fn register(f: &mut HashMap<String, Builtin>) {
|
||||
|
@ -2,7 +2,7 @@ use std::collections::HashMap;
|
||||
|
||||
use super::{Builtin, GLOBAL_FUNCTIONS};
|
||||
use crate::common::QuoteKind;
|
||||
use crate::units::Unit;
|
||||
use crate::unit::Unit;
|
||||
use crate::value::Value;
|
||||
|
||||
pub(crate) fn register(f: &mut HashMap<String, Builtin>) {
|
||||
|
@ -6,7 +6,7 @@ use num_traits::sign::Signed;
|
||||
|
||||
use super::Builtin;
|
||||
use crate::common::QuoteKind;
|
||||
use crate::units::Unit;
|
||||
use crate::unit::Unit;
|
||||
use crate::value::{Number, Value};
|
||||
|
||||
pub(crate) fn register(f: &mut HashMap<String, Builtin>) {
|
||||
|
@ -115,7 +115,7 @@ mod mixin;
|
||||
mod scope;
|
||||
mod selector;
|
||||
mod style;
|
||||
mod units;
|
||||
mod unit;
|
||||
mod utils;
|
||||
mod value;
|
||||
|
||||
|
154
src/unit/conversion.rs
Normal file
154
src/unit/conversion.rs
Normal file
@ -0,0 +1,154 @@
|
||||
use std::collections::HashMap;
|
||||
use std::f64::consts::PI;
|
||||
use std::string::ToString;
|
||||
|
||||
use once_cell::sync::Lazy;
|
||||
|
||||
use crate::value::Number;
|
||||
|
||||
pub(crate) static UNIT_CONVERSION_TABLE: Lazy<HashMap<String, HashMap<String, Number>>> =
|
||||
Lazy::new(|| {
|
||||
let mut from_in = HashMap::new();
|
||||
from_in.insert("in".to_string(), Number::from(1));
|
||||
from_in.insert("cm".to_string(), Number::from(1) / Number::from(2.54));
|
||||
from_in.insert("pc".to_string(), Number::ratio(1, 6));
|
||||
from_in.insert("mm".to_string(), Number::from(1) / Number::from(25.4));
|
||||
from_in.insert("q".to_string(), Number::from(1) / Number::from(101.6));
|
||||
from_in.insert("pt".to_string(), Number::ratio(1, 72));
|
||||
from_in.insert("px".to_string(), Number::ratio(1, 96));
|
||||
|
||||
let mut from_cm = HashMap::new();
|
||||
from_cm.insert("in".to_string(), Number::from(2.54));
|
||||
from_cm.insert("cm".to_string(), Number::from(1));
|
||||
from_cm.insert("pc".to_string(), Number::from(2.54) / Number::from(6));
|
||||
from_cm.insert("mm".to_string(), Number::ratio(1, 10));
|
||||
from_cm.insert("q".to_string(), Number::ratio(1, 40));
|
||||
from_cm.insert("pt".to_string(), Number::from(2.54) / Number::from(72));
|
||||
from_cm.insert("px".to_string(), Number::from(2.54) / Number::from(96));
|
||||
|
||||
let mut from_pc = HashMap::new();
|
||||
from_pc.insert("in".to_string(), Number::from(6));
|
||||
from_pc.insert("cm".to_string(), Number::from(6) / Number::from(2.54));
|
||||
from_pc.insert("pc".to_string(), Number::from(1));
|
||||
from_pc.insert("mm".to_string(), Number::from(6) / Number::from(25.4));
|
||||
from_pc.insert("q".to_string(), Number::from(6) / Number::from(101.6));
|
||||
from_pc.insert("pt".to_string(), Number::ratio(1, 12));
|
||||
from_pc.insert("px".to_string(), Number::ratio(1, 16));
|
||||
|
||||
let mut from_mm = HashMap::new();
|
||||
from_mm.insert("in".to_string(), Number::from(25.4));
|
||||
from_mm.insert("cm".to_string(), Number::from(10));
|
||||
from_mm.insert("pc".to_string(), Number::from(25.4) / Number::from(6));
|
||||
from_mm.insert("mm".to_string(), Number::from(1));
|
||||
from_mm.insert("q".to_string(), Number::ratio(1, 4));
|
||||
from_mm.insert("pt".to_string(), Number::from(25.4) / Number::from(72));
|
||||
from_mm.insert("px".to_string(), Number::from(25.4) / Number::from(96));
|
||||
|
||||
let mut from_q = HashMap::new();
|
||||
from_q.insert("in".to_string(), Number::from(101.6));
|
||||
from_q.insert("cm".to_string(), Number::from(40));
|
||||
from_q.insert("pc".to_string(), Number::from(101.6) / Number::from(6));
|
||||
from_q.insert("mm".to_string(), Number::from(4));
|
||||
from_q.insert("q".to_string(), Number::from(1));
|
||||
from_q.insert("pt".to_string(), Number::from(101.6) / Number::from(72));
|
||||
from_q.insert("px".to_string(), Number::from(101.6) / Number::from(96));
|
||||
|
||||
let mut from_pt = HashMap::new();
|
||||
from_pt.insert("in".to_string(), Number::from(72));
|
||||
from_pt.insert("cm".to_string(), Number::from(72) / Number::from(2.54));
|
||||
from_pt.insert("pc".to_string(), Number::from(12));
|
||||
from_pt.insert("mm".to_string(), Number::from(72) / Number::from(25.4));
|
||||
from_pt.insert("q".to_string(), Number::from(72) / Number::from(101.6));
|
||||
from_pt.insert("pt".to_string(), Number::from(1));
|
||||
from_pt.insert("px".to_string(), Number::ratio(3, 4));
|
||||
|
||||
let mut from_px = HashMap::new();
|
||||
from_px.insert("in".to_string(), Number::from(96));
|
||||
from_px.insert("cm".to_string(), Number::from(96) / Number::from(2.54));
|
||||
from_px.insert("pc".to_string(), Number::from(16));
|
||||
from_px.insert("mm".to_string(), Number::from(96) / Number::from(25.4));
|
||||
from_px.insert("q".to_string(), Number::from(96) / Number::from(101.6));
|
||||
from_px.insert("pt".to_string(), Number::ratio(4, 3));
|
||||
from_px.insert("px".to_string(), Number::from(1));
|
||||
|
||||
let mut from_deg = HashMap::new();
|
||||
from_deg.insert("deg".to_string(), Number::from(1));
|
||||
from_deg.insert("grad".to_string(), Number::ratio(9, 10));
|
||||
from_deg.insert("rad".to_string(), Number::from(180) / Number::from(PI));
|
||||
from_deg.insert("turn".to_string(), Number::from(360));
|
||||
|
||||
let mut from_grad = HashMap::new();
|
||||
from_grad.insert("deg".to_string(), Number::ratio(10, 9));
|
||||
from_grad.insert("grad".to_string(), Number::from(1));
|
||||
from_grad.insert("rad".to_string(), Number::from(200) / Number::from(PI));
|
||||
from_grad.insert("turn".to_string(), Number::from(400));
|
||||
|
||||
let mut from_rad = HashMap::new();
|
||||
from_rad.insert("deg".to_string(), Number::from(PI) / Number::from(180));
|
||||
from_rad.insert("grad".to_string(), Number::from(PI) / Number::from(200));
|
||||
from_rad.insert("rad".to_string(), Number::from(1));
|
||||
from_rad.insert("turn".to_string(), Number::from(2.0 * PI));
|
||||
|
||||
let mut from_turn = HashMap::new();
|
||||
from_turn.insert("deg".to_string(), Number::ratio(1, 360));
|
||||
from_turn.insert("grad".to_string(), Number::ratio(1, 400));
|
||||
from_turn.insert("rad".to_string(), Number::from(1) / Number::from(2.0 * PI));
|
||||
from_turn.insert("turn".to_string(), Number::from(1));
|
||||
|
||||
let mut from_s = HashMap::new();
|
||||
from_s.insert("s".to_string(), Number::from(1));
|
||||
from_s.insert("ms".to_string(), Number::ratio(1, 1000));
|
||||
|
||||
let mut from_ms = HashMap::new();
|
||||
from_ms.insert("s".to_string(), Number::from(1000));
|
||||
from_ms.insert("ms".to_string(), Number::from(1));
|
||||
|
||||
let mut from_hz = HashMap::new();
|
||||
from_hz.insert("Hz".to_string(), Number::from(1));
|
||||
from_hz.insert("kHz".to_string(), Number::from(1000));
|
||||
|
||||
let mut from_khz = HashMap::new();
|
||||
from_khz.insert("Hz".to_string(), Number::ratio(1, 1000));
|
||||
from_khz.insert("kHz".to_string(), Number::from(1));
|
||||
|
||||
let mut from_dpi = HashMap::new();
|
||||
from_dpi.insert("dpi".to_string(), Number::from(1));
|
||||
from_dpi.insert("dpcm".to_string(), Number::from(2.54));
|
||||
from_dpi.insert("dppx".to_string(), Number::from(96));
|
||||
|
||||
let mut from_dpcm = HashMap::new();
|
||||
from_dpcm.insert("dpi".to_string(), Number::from(1) / Number::from(2.54));
|
||||
from_dpcm.insert("dpcm".to_string(), Number::from(1));
|
||||
from_dpcm.insert("dppx".to_string(), Number::from(96) / Number::from(2.54));
|
||||
|
||||
let mut from_dppx = HashMap::new();
|
||||
from_dppx.insert("dpi".to_string(), Number::ratio(1, 96));
|
||||
from_dppx.insert("dpcm".to_string(), Number::from(2.54) / Number::from(96));
|
||||
from_dppx.insert("dppx".to_string(), Number::from(1));
|
||||
|
||||
let mut m = HashMap::new();
|
||||
m.insert("in".to_string(), from_in);
|
||||
m.insert("cm".to_string(), from_cm);
|
||||
m.insert("pc".to_string(), from_pc);
|
||||
m.insert("mm".to_string(), from_mm);
|
||||
m.insert("q".to_string(), from_q);
|
||||
m.insert("pt".to_string(), from_pt);
|
||||
m.insert("px".to_string(), from_px);
|
||||
|
||||
m.insert("deg".to_string(), from_deg);
|
||||
m.insert("grad".to_string(), from_grad);
|
||||
m.insert("rad".to_string(), from_rad);
|
||||
m.insert("turn".to_string(), from_turn);
|
||||
|
||||
m.insert("s".to_string(), from_s);
|
||||
m.insert("ms".to_string(), from_ms);
|
||||
|
||||
m.insert("Hz".to_string(), from_hz);
|
||||
m.insert("kHz".to_string(), from_khz);
|
||||
|
||||
m.insert("dpi".to_string(), from_dpi);
|
||||
m.insert("dpcm".to_string(), from_dpcm);
|
||||
m.insert("dppx".to_string(), from_dppx);
|
||||
|
||||
m
|
||||
});
|
@ -1,158 +1,8 @@
|
||||
use std::collections::HashMap;
|
||||
use std::f64::consts::PI;
|
||||
use std::fmt;
|
||||
use std::string::ToString;
|
||||
|
||||
use once_cell::sync::Lazy;
|
||||
pub(crate) use conversion::UNIT_CONVERSION_TABLE;
|
||||
|
||||
use crate::value::Number;
|
||||
|
||||
pub(crate) static UNIT_CONVERSION_TABLE: Lazy<HashMap<String, HashMap<String, Number>>> =
|
||||
Lazy::new(|| {
|
||||
let mut from_in = HashMap::new();
|
||||
from_in.insert("in".to_string(), Number::from(1));
|
||||
from_in.insert("cm".to_string(), Number::from(1) / Number::from(2.54));
|
||||
from_in.insert("pc".to_string(), Number::ratio(1, 6));
|
||||
from_in.insert("mm".to_string(), Number::from(1) / Number::from(25.4));
|
||||
from_in.insert("q".to_string(), Number::from(1) / Number::from(101.6));
|
||||
from_in.insert("pt".to_string(), Number::ratio(1, 72));
|
||||
from_in.insert("px".to_string(), Number::ratio(1, 96));
|
||||
|
||||
let mut from_cm = HashMap::new();
|
||||
from_cm.insert("in".to_string(), Number::from(2.54));
|
||||
from_cm.insert("cm".to_string(), Number::from(1));
|
||||
from_cm.insert("pc".to_string(), Number::from(2.54) / Number::from(6));
|
||||
from_cm.insert("mm".to_string(), Number::ratio(1, 10));
|
||||
from_cm.insert("q".to_string(), Number::ratio(1, 40));
|
||||
from_cm.insert("pt".to_string(), Number::from(2.54) / Number::from(72));
|
||||
from_cm.insert("px".to_string(), Number::from(2.54) / Number::from(96));
|
||||
|
||||
let mut from_pc = HashMap::new();
|
||||
from_pc.insert("in".to_string(), Number::from(6));
|
||||
from_pc.insert("cm".to_string(), Number::from(6) / Number::from(2.54));
|
||||
from_pc.insert("pc".to_string(), Number::from(1));
|
||||
from_pc.insert("mm".to_string(), Number::from(6) / Number::from(25.4));
|
||||
from_pc.insert("q".to_string(), Number::from(6) / Number::from(101.6));
|
||||
from_pc.insert("pt".to_string(), Number::ratio(1, 12));
|
||||
from_pc.insert("px".to_string(), Number::ratio(1, 16));
|
||||
|
||||
let mut from_mm = HashMap::new();
|
||||
from_mm.insert("in".to_string(), Number::from(25.4));
|
||||
from_mm.insert("cm".to_string(), Number::from(10));
|
||||
from_mm.insert("pc".to_string(), Number::from(25.4) / Number::from(6));
|
||||
from_mm.insert("mm".to_string(), Number::from(1));
|
||||
from_mm.insert("q".to_string(), Number::ratio(1, 4));
|
||||
from_mm.insert("pt".to_string(), Number::from(25.4) / Number::from(72));
|
||||
from_mm.insert("px".to_string(), Number::from(25.4) / Number::from(96));
|
||||
|
||||
let mut from_q = HashMap::new();
|
||||
from_q.insert("in".to_string(), Number::from(101.6));
|
||||
from_q.insert("cm".to_string(), Number::from(40));
|
||||
from_q.insert("pc".to_string(), Number::from(101.6) / Number::from(6));
|
||||
from_q.insert("mm".to_string(), Number::from(4));
|
||||
from_q.insert("q".to_string(), Number::from(1));
|
||||
from_q.insert("pt".to_string(), Number::from(101.6) / Number::from(72));
|
||||
from_q.insert("px".to_string(), Number::from(101.6) / Number::from(96));
|
||||
|
||||
let mut from_pt = HashMap::new();
|
||||
from_pt.insert("in".to_string(), Number::from(72));
|
||||
from_pt.insert("cm".to_string(), Number::from(72) / Number::from(2.54));
|
||||
from_pt.insert("pc".to_string(), Number::from(12));
|
||||
from_pt.insert("mm".to_string(), Number::from(72) / Number::from(25.4));
|
||||
from_pt.insert("q".to_string(), Number::from(72) / Number::from(101.6));
|
||||
from_pt.insert("pt".to_string(), Number::from(1));
|
||||
from_pt.insert("px".to_string(), Number::ratio(3, 4));
|
||||
|
||||
let mut from_px = HashMap::new();
|
||||
from_px.insert("in".to_string(), Number::from(96));
|
||||
from_px.insert("cm".to_string(), Number::from(96) / Number::from(2.54));
|
||||
from_px.insert("pc".to_string(), Number::from(16));
|
||||
from_px.insert("mm".to_string(), Number::from(96) / Number::from(25.4));
|
||||
from_px.insert("q".to_string(), Number::from(96) / Number::from(101.6));
|
||||
from_px.insert("pt".to_string(), Number::ratio(4, 3));
|
||||
from_px.insert("px".to_string(), Number::from(1));
|
||||
|
||||
let mut from_deg = HashMap::new();
|
||||
from_deg.insert("deg".to_string(), Number::from(1));
|
||||
from_deg.insert("grad".to_string(), Number::ratio(9, 10));
|
||||
from_deg.insert("rad".to_string(), Number::from(180) / Number::from(PI));
|
||||
from_deg.insert("turn".to_string(), Number::from(360));
|
||||
|
||||
let mut from_grad = HashMap::new();
|
||||
from_grad.insert("deg".to_string(), Number::ratio(10, 9));
|
||||
from_grad.insert("grad".to_string(), Number::from(1));
|
||||
from_grad.insert("rad".to_string(), Number::from(200) / Number::from(PI));
|
||||
from_grad.insert("turn".to_string(), Number::from(400));
|
||||
|
||||
let mut from_rad = HashMap::new();
|
||||
from_rad.insert("deg".to_string(), Number::from(PI) / Number::from(180));
|
||||
from_rad.insert("grad".to_string(), Number::from(PI) / Number::from(200));
|
||||
from_rad.insert("rad".to_string(), Number::from(1));
|
||||
from_rad.insert("turn".to_string(), Number::from(2.0 * PI));
|
||||
|
||||
let mut from_turn = HashMap::new();
|
||||
from_turn.insert("deg".to_string(), Number::ratio(1, 360));
|
||||
from_turn.insert("grad".to_string(), Number::ratio(1, 400));
|
||||
from_turn.insert("rad".to_string(), Number::from(1) / Number::from(2.0 * PI));
|
||||
from_turn.insert("turn".to_string(), Number::from(1));
|
||||
|
||||
let mut from_s = HashMap::new();
|
||||
from_s.insert("s".to_string(), Number::from(1));
|
||||
from_s.insert("ms".to_string(), Number::ratio(1, 1000));
|
||||
|
||||
let mut from_ms = HashMap::new();
|
||||
from_ms.insert("s".to_string(), Number::from(1000));
|
||||
from_ms.insert("ms".to_string(), Number::from(1));
|
||||
|
||||
let mut from_hz = HashMap::new();
|
||||
from_hz.insert("Hz".to_string(), Number::from(1));
|
||||
from_hz.insert("kHz".to_string(), Number::from(1000));
|
||||
|
||||
let mut from_khz = HashMap::new();
|
||||
from_khz.insert("Hz".to_string(), Number::ratio(1, 1000));
|
||||
from_khz.insert("kHz".to_string(), Number::from(1));
|
||||
|
||||
let mut from_dpi = HashMap::new();
|
||||
from_dpi.insert("dpi".to_string(), Number::from(1));
|
||||
from_dpi.insert("dpcm".to_string(), Number::from(2.54));
|
||||
from_dpi.insert("dppx".to_string(), Number::from(96));
|
||||
|
||||
let mut from_dpcm = HashMap::new();
|
||||
from_dpcm.insert("dpi".to_string(), Number::from(1) / Number::from(2.54));
|
||||
from_dpcm.insert("dpcm".to_string(), Number::from(1));
|
||||
from_dpcm.insert("dppx".to_string(), Number::from(96) / Number::from(2.54));
|
||||
|
||||
let mut from_dppx = HashMap::new();
|
||||
from_dppx.insert("dpi".to_string(), Number::ratio(1, 96));
|
||||
from_dppx.insert("dpcm".to_string(), Number::from(2.54) / Number::from(96));
|
||||
from_dppx.insert("dppx".to_string(), Number::from(1));
|
||||
|
||||
let mut m = HashMap::new();
|
||||
m.insert("in".to_string(), from_in);
|
||||
m.insert("cm".to_string(), from_cm);
|
||||
m.insert("pc".to_string(), from_pc);
|
||||
m.insert("mm".to_string(), from_mm);
|
||||
m.insert("q".to_string(), from_q);
|
||||
m.insert("pt".to_string(), from_pt);
|
||||
m.insert("px".to_string(), from_px);
|
||||
|
||||
m.insert("deg".to_string(), from_deg);
|
||||
m.insert("grad".to_string(), from_grad);
|
||||
m.insert("rad".to_string(), from_rad);
|
||||
m.insert("turn".to_string(), from_turn);
|
||||
|
||||
m.insert("s".to_string(), from_s);
|
||||
m.insert("ms".to_string(), from_ms);
|
||||
|
||||
m.insert("Hz".to_string(), from_hz);
|
||||
m.insert("kHz".to_string(), from_khz);
|
||||
|
||||
m.insert("dpi".to_string(), from_dpi);
|
||||
m.insert("dpcm".to_string(), from_dpcm);
|
||||
m.insert("dppx".to_string(), from_dppx);
|
||||
|
||||
m
|
||||
});
|
||||
mod conversion;
|
||||
|
||||
#[derive(Clone, Debug, Eq, PartialEq)]
|
||||
pub(crate) enum Unit {
|
@ -4,7 +4,7 @@ use std::iter::Iterator;
|
||||
use crate::color::Color;
|
||||
use crate::common::{ListSeparator, Op, QuoteKind};
|
||||
use crate::error::SassResult;
|
||||
use crate::units::Unit;
|
||||
use crate::unit::Unit;
|
||||
pub(crate) use number::Number;
|
||||
|
||||
mod number;
|
||||
|
@ -2,7 +2,7 @@ use std::ops::{Add, Div, Mul, Rem, Sub};
|
||||
|
||||
use crate::common::QuoteKind;
|
||||
use crate::error::SassResult;
|
||||
use crate::units::{Unit, UNIT_CONVERSION_TABLE};
|
||||
use crate::unit::{Unit, UNIT_CONVERSION_TABLE};
|
||||
use crate::value::Value;
|
||||
|
||||
impl Add for Value {
|
||||
@ -116,7 +116,7 @@ impl Add for Value {
|
||||
}
|
||||
Self::Paren(..) => (self + other.eval()?)?,
|
||||
_ => Value::Ident(format!("{}{}", self, other), QuoteKind::None),
|
||||
}
|
||||
},
|
||||
})
|
||||
}
|
||||
}
|
||||
@ -209,7 +209,10 @@ impl Sub for Value {
|
||||
QuoteKind::Double | QuoteKind::Single => QuoteKind::Double,
|
||||
QuoteKind::None => QuoteKind::None,
|
||||
};
|
||||
Value::Ident(format!("{}{}{}-{}", quotes, s1, quotes, other), QuoteKind::None)
|
||||
Value::Ident(
|
||||
format!("{}{}{}-{}", quotes, s1, quotes, other),
|
||||
QuoteKind::None,
|
||||
)
|
||||
}
|
||||
_ => todo!(),
|
||||
},
|
||||
@ -219,11 +222,14 @@ 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::Paren(..) => (self + other.eval()?)?,
|
||||
_ => Value::Ident(format!("{}-{}", self, other), QuoteKind::None),
|
||||
}
|
||||
},
|
||||
_ => match other {
|
||||
Self::Ident(s, quotes) => {
|
||||
let quotes = match quotes {
|
||||
|
@ -12,7 +12,7 @@ use crate::common::{Keyword, ListSeparator, Op, QuoteKind, Symbol};
|
||||
use crate::error::SassResult;
|
||||
use crate::scope::Scope;
|
||||
use crate::selector::Selector;
|
||||
use crate::units::Unit;
|
||||
use crate::unit::Unit;
|
||||
use crate::utils::{
|
||||
devour_whitespace_or_comment, flatten_ident, parse_interpolation, parse_quoted_string,
|
||||
};
|
||||
|
Loading…
x
Reference in New Issue
Block a user