diff options
| author | Urgau <urgau@numericable.fr> | 2022-10-05 23:18:22 +0200 |
|---|---|---|
| committer | Urgau <urgau@numericable.fr> | 2022-10-08 11:00:13 +0200 |
| commit | c084c263977ba7376ce944b9dd6b8dffdc2eee48 (patch) | |
| tree | 1586b6bd19f7b9a3a2c83c2b5e45caf86138985b /src/doc | |
| parent | a688a0305fad9219505a8f2576446510601bafe8 (diff) | |
| download | rust-c084c263977ba7376ce944b9dd6b8dffdc2eee48.tar.gz rust-c084c263977ba7376ce944b9dd6b8dffdc2eee48.zip | |
Split slice part of feature(half_open_range_patterns) to [...]_in_slices
Diffstat (limited to 'src/doc')
| -rw-r--r-- | src/doc/unstable-book/src/language-features/half-open-range-patterns-in-slices.md | 30 |
1 files changed, 30 insertions, 0 deletions
diff --git a/src/doc/unstable-book/src/language-features/half-open-range-patterns-in-slices.md b/src/doc/unstable-book/src/language-features/half-open-range-patterns-in-slices.md new file mode 100644 index 00000000000..56a1a97df16 --- /dev/null +++ b/src/doc/unstable-book/src/language-features/half-open-range-patterns-in-slices.md @@ -0,0 +1,30 @@ +# `half_open_range_patterns_in_slices` + +The tracking issue for this feature is: [#67264] +It is part of the `exclusive_range_pattern` feature, +tracked at [#37854]. + +[#67264]: https://github.com/rust-lang/rust/issues/67264 +[#37854]: https://github.com/rust-lang/rust/issues/37854 +----- + +This feature allow using top-level half-open range patterns in slices. + +```rust +#![feature(half_open_range_patterns_in_slices)] +#![feature(exclusive_range_pattern)] + +fn main() { + let xs = [13, 1, 5, 2, 3, 1, 21, 8]; + let [a @ 3.., b @ ..3, c @ 4..6, ..] = xs else { return; }; +} +``` + +Note that this feature is not required if the patterns are wrapped between parenthesis. + +```rust +fn main() { + let xs = [13, 1]; + let [(a @ 3..), c] = xs else { return; }; +} +``` |
