diff options
| author | Laurenz <laurmaedje@gmail.com> | 2020-10-04 23:31:35 +0200 |
|---|---|---|
| committer | Laurenz <laurmaedje@gmail.com> | 2020-10-04 23:31:35 +0200 |
| commit | 335fa2d118718b4dba539294a8ef6c96c5bbf09e (patch) | |
| tree | 08e48d0c18c350bc9479d0d801d2320628d8e4a2 /src/eval/value.rs | |
| parent | 605ab104c5e041c345007020d277b4c6267debe6 (diff) | |
Small improvements 🍪
Diffstat (limited to 'src/eval/value.rs')
| -rw-r--r-- | src/eval/value.rs | 28 |
1 files changed, 14 insertions, 14 deletions
diff --git a/src/eval/value.rs b/src/eval/value.rs index 2d83c8d0..85cb261c 100644 --- a/src/eval/value.rs +++ b/src/eval/value.rs @@ -1,4 +1,4 @@ -//! Computational values: Syntactical expressions can be evaluated into these. +//! Computational values. use std::fmt::{self, Debug, Formatter}; use std::ops::Deref; @@ -57,9 +57,9 @@ impl Value { pub fn ty(&self) -> &'static str { match self { Self::None => "none", - Self::Ident(_) => "ident", + Self::Ident(_) => "identifier", Self::Bool(_) => "bool", - Self::Int(_) => "int", + Self::Int(_) => "integer", Self::Float(_) => "float", Self::Relative(_) => "relative", Self::Length(_) => "length", @@ -88,6 +88,9 @@ impl Spanned<Value> { /// the value is represented as layoutable content in a reasonable way. pub fn into_commands(self) -> Vec<Command> { match self.v { + // Don't print out none values. + Value::None => vec![], + // Pass-through. Value::Commands(commands) => commands, Value::Content(tree) => vec![Command::LayoutSyntaxTree(tree)], @@ -109,9 +112,6 @@ impl Spanned<Value> { commands } - // Don't print out none values. - Value::None => vec![], - // Format with debug. val => { let fmt = format!("{:?}", val); @@ -144,6 +144,14 @@ impl Debug for Value { } } +/// A dictionary of values. +/// +/// # Example +/// ```typst +/// (false, 12cm, greeting="hi") +/// ``` +pub type ValueDict = Dict<SpannedEntry<Value>>; + /// An wrapper around a reference-counted executable function value. /// /// The dynamic function object is wrapped in an `Rc` to keep [`Value`] @@ -192,11 +200,3 @@ impl Debug for ValueFunc { f.pad("<function>") } } - -/// A dictionary of values. -/// -/// # Example -/// ```typst -/// (false, 12cm, greeting="hi") -/// ``` -pub type ValueDict = Dict<SpannedEntry<Value>>; |
