From 335fa2d118718b4dba539294a8ef6c96c5bbf09e Mon Sep 17 00:00:00 2001 From: Laurenz Date: Sun, 4 Oct 2020 23:31:35 +0200 Subject: =?UTF-8?q?Small=20improvements=20=F0=9F=8D=AA?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/eval/value.rs | 28 ++++++++++++++-------------- 1 file changed, 14 insertions(+), 14 deletions(-) (limited to 'src/eval/value.rs') 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 { /// the value is represented as layoutable content in a reasonable way. pub fn into_commands(self) -> Vec { 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 { 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>; + /// 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("") } } - -/// A dictionary of values. -/// -/// # Example -/// ```typst -/// (false, 12cm, greeting="hi") -/// ``` -pub type ValueDict = Dict>; -- cgit v1.2.3