mirror of
https://github.com/typst/typst
synced 2025-07-01 17:52:52 +08:00
parent
1603e2df26
commit
e182777133
@ -473,9 +473,18 @@ impl Array {
|
|||||||
#[variadic]
|
#[variadic]
|
||||||
others: Vec<Array>,
|
others: Vec<Array>,
|
||||||
) -> SourceResult<Array> {
|
) -> SourceResult<Array> {
|
||||||
// Fast path for just two arrays.
|
|
||||||
let mut args = args;
|
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")?;
|
let other = args.expect::<Array>("others")?;
|
||||||
args.finish()?;
|
args.finish()?;
|
||||||
return Ok(self
|
return Ok(self
|
||||||
|
@ -260,6 +260,9 @@
|
|||||||
#test((1, 2, 3).zip((3, 4, 5), (6, 7, 8)), ((1, 3, 6), (2, 4, 7), (3, 5, 8)))
|
#test((1, 2, 3).zip((3, 4, 5), (6, 7, 8)), ((1, 3, 6), (2, 4, 7), (3, 5, 8)))
|
||||||
#test(().zip((), ()), ())
|
#test(().zip((), ()), ())
|
||||||
#test((1,).zip((2,), (3,)), ((1, 2, 3),))
|
#test((1,).zip((2,), (3,)), ((1, 2, 3),))
|
||||||
|
#test((1, 2, 3).zip(), ((1,), (2,), (3,)))
|
||||||
|
#test(array.zip(()), ())
|
||||||
|
#test(array.zip(("a", "b")), (("a",), ("b",)))
|
||||||
|
|
||||||
---
|
---
|
||||||
// Test the `enumerate` method.
|
// Test the `enumerate` method.
|
||||||
|
Loading…
x
Reference in New Issue
Block a user