summaryrefslogtreecommitdiff
path: root/src/eval/ops.rs
diff options
context:
space:
mode:
authorLaurenz <laurmaedje@gmail.com>2022-03-11 12:59:55 +0100
committerLaurenz <laurmaedje@gmail.com>2022-03-11 23:36:06 +0100
commit5ac7eb3860ebd3247f6486c227e816894cb8fd91 (patch)
treea29a868c681c7de39f15f2d9d3f031db1861b90a /src/eval/ops.rs
parent5ce2a006b6d45d29be15e4562ae3ab4fc1b8e97c (diff)
Rename template to content
Diffstat (limited to 'src/eval/ops.rs')
-rw-r--r--src/eval/ops.rs25
1 files changed, 13 insertions, 12 deletions
diff --git a/src/eval/ops.rs b/src/eval/ops.rs
index acceb626..04a13fd1 100644
--- a/src/eval/ops.rs
+++ b/src/eval/ops.rs
@@ -19,11 +19,11 @@ pub fn join(lhs: Value, rhs: Value) -> StrResult<Value> {
(a, None) => a,
(None, b) => b,
(Str(a), Str(b)) => Str(a + b),
+ (Str(a), Content(b)) => Content(super::Content::Text(a) + b),
+ (Content(a), Str(b)) => Content(a + super::Content::Text(b)),
+ (Content(a), Content(b)) => Content(a + b),
(Array(a), Array(b)) => Array(a + b),
(Dict(a), Dict(b)) => Dict(a + b),
- (Template(a), Template(b)) => Template(a + b),
- (Template(a), Str(b)) => Template(a + super::Template::Text(b)),
- (Str(a), Template(b)) => Template(super::Template::Text(a) + b),
(a, b) => mismatch!("cannot join {} with {}", a, b),
})
}
@@ -81,15 +81,16 @@ pub fn add(lhs: Value, rhs: Value) -> StrResult<Value> {
(Fractional(a), Fractional(b)) => Fractional(a + b),
(Str(a), Str(b)) => Str(a + b),
+
+ (Content(a), None) => Content(a),
+ (None, Content(b)) => Content(b),
+ (Content(a), Content(b)) => Content(a + b),
+ (Content(a), Str(b)) => Content(a + super::Content::Text(b)),
+ (Str(a), Content(b)) => Content(super::Content::Text(a) + b),
+
(Array(a), Array(b)) => Array(a + b),
(Dict(a), Dict(b)) => Dict(a + b),
- (Template(a), None) => Template(a),
- (None, Template(b)) => Template(b),
- (Template(a), Template(b)) => Template(a + b),
- (Template(a), Str(b)) => Template(a + super::Template::Text(b)),
- (Str(a), Template(b)) => Template(super::Template::Text(a) + b),
-
(a, b) => {
if let (Dyn(a), Dyn(b)) = (&a, &b) {
// 1D alignments can be summed into 2D alignments.
@@ -177,8 +178,8 @@ pub fn mul(lhs: Value, rhs: Value) -> StrResult<Value> {
(Int(a), Str(b)) => Str(repeat_str(b, a)?),
(Array(a), Int(b)) => Array(a.repeat(b)?),
(Int(a), Array(b)) => Array(b.repeat(a)?),
- (Template(a), Int(b)) => Template(a.repeat(b)?),
- (Int(a), Template(b)) => Template(b.repeat(a)?),
+ (Content(a), Int(b)) => Content(a.repeat(b)?),
+ (Int(a), Content(b)) => Content(b.repeat(a)?),
(a, b) => mismatch!("cannot multiply {} with {}", a, b),
})
@@ -293,9 +294,9 @@ pub fn equal(lhs: &Value, rhs: &Value) -> bool {
(Fractional(a), Fractional(b)) => a == b,
(Color(a), Color(b)) => a == b,
(Str(a), Str(b)) => a == b,
+ (Content(a), Content(b)) => a == b,
(Array(a), Array(b)) => a == b,
(Dict(a), Dict(b)) => a == b,
- (Template(a), Template(b)) => a == b,
(Func(a), Func(b)) => a == b,
(Dyn(a), Dyn(b)) => a == b,