summaryrefslogtreecommitdiff
path: root/crates
diff options
context:
space:
mode:
authorJoseph Wilson <jo.alex.w@gmail.com>2023-10-27 23:58:55 +1300
committerGitHub <noreply@github.com>2023-10-27 12:58:55 +0200
commite18277713336b6f53554bb76d6690043ce28faef (patch)
tree745673b3051b88c95543563589b4e1f37d753b96 /crates
parent1603e2df268dbcf4bddd2a019ddc39bce3454883 (diff)
Implement unary `array.zip`, closing #2478 (#2491)
Diffstat (limited to 'crates')
-rw-r--r--crates/typst/src/eval/array.rs13
1 files changed, 11 insertions, 2 deletions
diff --git a/crates/typst/src/eval/array.rs b/crates/typst/src/eval/array.rs
index bee3fae7..f139907f 100644
--- a/crates/typst/src/eval/array.rs
+++ b/crates/typst/src/eval/array.rs
@@ -473,9 +473,18 @@ impl Array {
#[variadic]
others: Vec<Array>,
) -> SourceResult<Array> {
- // Fast path for just two arrays.
let mut args = args;
- if args.remaining() <= 1 {
+
+ // Fast path for one array.
+ if args.remaining() == 0 {
+ return Ok(self
+ .iter()
+ .map(|item| array![item.clone()].into_value())
+ .collect());
+ }
+
+ // Fast path for just two arrays.
+ if args.remaining() == 1 {
let other = args.expect::<Array>("others")?;
args.finish()?;
return Ok(self