Plurrrr

Tue 17 Aug 2021

Slice Patterns

Rust 1.26 introduced a nifty little feature called Basic Slice Patterns which lets you pattern match on slices with a known length. Later on in Rust 1.42, this was extended to allow using .. to match on “everything else”.

As features go this may seem like a small addition, but it gives developers an opportunity to write much more expressive code.

Source: Slice Patterns, an article by Michael F. Bryan.