corollary
corollary copied to clipboard
How can you match on an empty array?
Say we're matching:
case value of
Container([]) => ...,
Container(vector) => ...,
This won't work in Rust if you try to match against a container. Unless box [] pattern works. Does this need an extensive AST transform to work?
Would slice patterns in nightly rustc work? https://doc.rust-lang.org/book/slice-patterns.html
Alternatively, use a pattern guard in a match?
Pattern guards are a good choice here, I think the pattern is just [] and non_empty_vec throughout the code!
Slice patterns would work, though only at the top-level. Pattern matching against Vectors and Strings is not possible unless they're converted into boxed objects first (and box_patterns is enabled), so I should get more data on how they're used.