diff options
| author | Jubilee Young <workingjubilee@gmail.com> | 2020-11-08 16:00:19 -0800 |
|---|---|---|
| committer | Jubilee Young <workingjubilee@gmail.com> | 2021-04-02 12:29:16 -0700 |
| commit | 6b98704df66d07fca3483ec834b39042352e0e77 (patch) | |
| tree | 6ced5d742ff8d2113a0986f77b1f62b3bf649e61 | |
| parent | 36bcf4069717b9dff90270d13b53a3b130329960 (diff) | |
| download | rust-6b98704df66d07fca3483ec834b39042352e0e77.tar.gz rust-6b98704df66d07fca3483ec834b39042352e0e77.zip | |
Add newer range patterns to unstable book
| -rw-r--r-- | src/doc/unstable-book/src/language-features/exclusive-range-pattern.md | 25 | ||||
| -rw-r--r-- | src/doc/unstable-book/src/language-features/half-open-range-patterns.md | 25 |
2 files changed, 50 insertions, 0 deletions
diff --git a/src/doc/unstable-book/src/language-features/exclusive-range-pattern.md b/src/doc/unstable-book/src/language-features/exclusive-range-pattern.md new file mode 100644 index 00000000000..a828551aa51 --- /dev/null +++ b/src/doc/unstable-book/src/language-features/exclusive-range-pattern.md @@ -0,0 +1,25 @@ +# `exclusive_range_pattern` + +The tracking issue for this feature is: [#37854]. + + +[#67264]: https://github.com/rust-lang/rust/issues/67264 +[#37854]: https://github.com/rust-lang/rust/issues/37854 +----- + +The `exclusive_range_pattern` feature allows non-inclusive range +patterns (`0..10`) to be used in appropriate pattern matching +contexts. It also can be combined with `#![feature(half_open_range_patterns]` +to be able to use RangeTo patterns (`..10`). + +It also enabled RangeFrom patterns but that has since been +stabilized. + +```rust +#![feature(exclusive_range_pattern)] + match x { + 0..10 => println!("single digit"), + 10 => println!("ten isn't part of the above range"), + _ => println!("nor is everything else.") + } +``` diff --git a/src/doc/unstable-book/src/language-features/half-open-range-patterns.md b/src/doc/unstable-book/src/language-features/half-open-range-patterns.md new file mode 100644 index 00000000000..b6ea510c0fb --- /dev/null +++ b/src/doc/unstable-book/src/language-features/half-open-range-patterns.md @@ -0,0 +1,25 @@ +# `half_open_range_patterns` + +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 +----- + +The `half_open_range_patterns` feature allows RangeTo patterns +(`..10`) to be used in appropriate pattern matching contexts. +This requires also enabling the `exclusive_range_pattern` feature. + +It also enabled RangeFrom patterns but that has since been +stabilized. + +```rust +#![feature(half_open_range_patterns)] +#![feature(exclusive_range_pattern)] + match x { + ..10 => println!("got it"), + 0 => println!("zilch") + } +``` |
