diff options
Diffstat (limited to 'src')
| -rw-r--r-- | src/model/scope.rs | 9 | ||||
| -rw-r--r-- | src/model/symbol.rs | 24 |
2 files changed, 3 insertions, 30 deletions
diff --git a/src/model/scope.rs b/src/model/scope.rs index 2e3b8244..18c75535 100644 --- a/src/model/scope.rs +++ b/src/model/scope.rs @@ -109,15 +109,6 @@ impl Scope { self.0.insert(var.into(), Slot::new(value.into(), Kind::Captured)); } - /// Copy definitions from another scope that aren't yet defined in this one. - pub fn copy_from(&mut self, other: &Self) { - for (name, value) in other.iter() { - self.0 - .entry(name.clone()) - .or_insert_with(|| Slot::new(value.clone(), Kind::Normal)); - } - } - /// Try to access a variable immutably. pub fn get(&self, var: &str) -> Option<&Value> { self.0.get(var).map(Slot::read) diff --git a/src/model/symbol.rs b/src/model/symbol.rs index 435048ac..9d226801 100644 --- a/src/model/symbol.rs +++ b/src/model/symbol.rs @@ -7,26 +7,8 @@ use crate::diag::StrResult; use crate::util::EcoString; /// Define a list of symbols. -#[macro_export] -#[doc(hidden)] -macro_rules! __symbols { - ($func:ident, $($name:ident: $value:tt),* $(,)?) => { - pub(super) fn $func(scope: &mut $crate::model::Scope) { - $(scope.define(stringify!($name), $crate::model::symbols!(@one $value));)* - } - }; - (@one $c:literal) => { $crate::model::Symbol::new($c) }; - (@one [$($first:literal $(: $second:literal)?),* $(,)?]) => { - $crate::model::Symbol::list(&[ - $($crate::model::symbols!(@pair $first $(: $second)?)),* - ]) - }; - (@pair $first:literal) => { ("", $first) }; - (@pair $first:literal: $second:literal) => { ($first, $second) }; -} - #[doc(inline)] -pub use crate::__symbols as symbols; +pub use typst_macros::symbols; /// A symbol. #[derive(Clone, Eq, PartialEq, Hash)] @@ -45,13 +27,13 @@ enum Repr { impl Symbol { /// Create a new symbol from a single character. - pub fn new(c: char) -> Self { + pub const fn new(c: char) -> Self { Self { repr: Repr::Single(c), modifiers: EcoString::new() } } /// Create a symbol with a static variant list. #[track_caller] - pub fn list(list: &'static [(&'static str, char)]) -> Self { + pub const fn list(list: &'static [(&'static str, char)]) -> Self { debug_assert!(!list.is_empty()); Self { repr: Repr::Static(list), |
