diff options
| author | Laurenz <laurmaedje@gmail.com> | 2022-10-28 16:43:38 +0200 |
|---|---|---|
| committer | Laurenz <laurmaedje@gmail.com> | 2022-10-28 16:43:38 +0200 |
| commit | 95e9134a3c7d7a14d8c8928413fdffc665671895 (patch) | |
| tree | 822b5f6c2d23aba33cfe4d199405e493e37c3d70 /src/syntax | |
| parent | 66030ae5d73d85a0463562230b87f8ec7554c746 (diff) | |
Refactor `geom` module
Diffstat (limited to 'src/syntax')
| -rw-r--r-- | src/syntax/kind.rs | 4 | ||||
| -rw-r--r-- | src/syntax/tokens.rs | 18 |
2 files changed, 11 insertions, 11 deletions
diff --git a/src/syntax/kind.rs b/src/syntax/kind.rs index 3273e72d..1568693b 100644 --- a/src/syntax/kind.rs +++ b/src/syntax/kind.rs @@ -1,7 +1,7 @@ use std::hash::{Hash, Hasher}; use std::sync::Arc; -use crate::geom::{AngleUnit, LengthUnit}; +use crate::geom::{AbsUnit, AngleUnit}; use crate::util::EcoString; /// All syntactical building blocks that can be part of a Typst document. @@ -277,7 +277,7 @@ pub struct RawKind { #[derive(Debug, Copy, Clone, Eq, PartialEq, Hash)] pub enum Unit { /// An absolute length unit. - Length(LengthUnit), + Length(AbsUnit), /// An angular unit. Angle(AngleUnit), /// Font-relative: `1em` is the same as the font size. diff --git a/src/syntax/tokens.rs b/src/syntax/tokens.rs index 8e1b6944..59e6cd3f 100644 --- a/src/syntax/tokens.rs +++ b/src/syntax/tokens.rs @@ -5,7 +5,7 @@ use unscanny::Scanner; use super::resolve::{resolve_hex, resolve_raw, resolve_string}; use super::{ErrorPos, NodeKind, RawKind, Unit}; -use crate::geom::{AngleUnit, LengthUnit}; +use crate::geom::{AbsUnit, AngleUnit}; use crate::util::EcoString; /// An iterator over the tokens of a string of source code. @@ -565,10 +565,10 @@ impl<'s> Tokens<'s> { match suffix { "" => NodeKind::Float(v), - "pt" => NodeKind::Numeric(v, Unit::Length(LengthUnit::Pt)), - "mm" => NodeKind::Numeric(v, Unit::Length(LengthUnit::Mm)), - "cm" => NodeKind::Numeric(v, Unit::Length(LengthUnit::Cm)), - "in" => NodeKind::Numeric(v, Unit::Length(LengthUnit::In)), + "pt" => NodeKind::Numeric(v, Unit::Length(AbsUnit::Pt)), + "mm" => NodeKind::Numeric(v, Unit::Length(AbsUnit::Mm)), + "cm" => NodeKind::Numeric(v, Unit::Length(AbsUnit::Cm)), + "in" => NodeKind::Numeric(v, Unit::Length(AbsUnit::In)), "deg" => NodeKind::Numeric(v, Unit::Angle(AngleUnit::Deg)), "rad" => NodeKind::Numeric(v, Unit::Angle(AngleUnit::Rad)), "em" => NodeKind::Numeric(v, Unit::Em), @@ -1089,10 +1089,10 @@ mod tests { let nums = ints.iter().map(|&(k, v)| (k, v as f64)).chain(floats); let suffixes: &[(&str, fn(f64) -> NodeKind)] = &[ - ("mm", |x| Numeric(x, Unit::Length(LengthUnit::Mm))), - ("pt", |x| Numeric(x, Unit::Length(LengthUnit::Pt))), - ("cm", |x| Numeric(x, Unit::Length(LengthUnit::Cm))), - ("in", |x| Numeric(x, Unit::Length(LengthUnit::In))), + ("mm", |x| Numeric(x, Unit::Length(AbsUnit::Mm))), + ("pt", |x| Numeric(x, Unit::Length(AbsUnit::Pt))), + ("cm", |x| Numeric(x, Unit::Length(AbsUnit::Cm))), + ("in", |x| Numeric(x, Unit::Length(AbsUnit::In))), ("rad", |x| Numeric(x, Unit::Angle(AngleUnit::Rad))), ("deg", |x| Numeric(x, Unit::Angle(AngleUnit::Deg))), ("em", |x| Numeric(x, Unit::Em)), |
