diff options
| author | Laurenz <laurmaedje@gmail.com> | 2020-09-30 14:38:46 +0200 |
|---|---|---|
| committer | Laurenz <laurmaedje@gmail.com> | 2020-09-30 14:38:46 +0200 |
| commit | 3c3730425f0a9a4241c4f57cb7f4d00b71db201e (patch) | |
| tree | 8e63405574bc3909dddc2d3e8402a66bb2a8f059 /src/compute | |
| parent | 7143e10afccc7beef22646f6c7355075f97afb2c (diff) | |
SpanWith trait ↔
Diffstat (limited to 'src/compute')
| -rw-r--r-- | src/compute/value.rs | 17 |
1 files changed, 8 insertions, 9 deletions
diff --git a/src/compute/value.rs b/src/compute/value.rs index 95219a5c..ef36e5d8 100644 --- a/src/compute/value.rs +++ b/src/compute/value.rs @@ -11,7 +11,7 @@ use crate::color::RgbaColor; use crate::layout::{Command, Commands, Dir, LayoutContext, SpecAlign}; use crate::length::{Length, ScaleLength}; use crate::paper::Paper; -use crate::syntax::{Ident, Span, Spanned, SyntaxNode, SyntaxTree}; +use crate::syntax::{Ident, Span, SpanWith, Spanned, SyntaxNode, SyntaxTree}; use crate::{DynFuture, Feedback, Pass}; /// A computational value. @@ -76,10 +76,8 @@ impl Spanned<Value> { for entry in table.into_values() { if let Some(last_end) = end { let span = Span::new(last_end, entry.key.start); - commands.push(Command::LayoutSyntaxTree(vec![Spanned::new( - SyntaxNode::Spacing, - span, - )])); + let tree = vec![SyntaxNode::Spacing.span_with(span)]; + commands.push(Command::LayoutSyntaxTree(tree)); } end = Some(entry.val.span.end); @@ -89,10 +87,11 @@ impl Spanned<Value> { } // Format with debug. - val => vec![Command::LayoutSyntaxTree(vec![Spanned::new( - SyntaxNode::Text(format!("{:?}", val)), - self.span, - )])], + val => { + let fmt = format!("{:?}", val); + let tree = vec![SyntaxNode::Text(fmt).span_with(self.span)]; + vec![Command::LayoutSyntaxTree(tree)] + } } } } |
