Skip to content

Commit 3fe5904

Browse files
Mark-SimulacrumCentrilpetrochenkov
authored
Apply suggestions from code review
Co-Authored-By: Mazdak Farrokhzad <[email protected]> Co-Authored-By: Vadim Petrochenkov <[email protected]>
1 parent 975b2e9 commit 3fe5904

File tree

1 file changed

+8
-8
lines changed

1 file changed

+8
-8
lines changed

posts/2020-03-12-Rust-1.42.md

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -81,13 +81,13 @@ The `..` is called a "rest pattern," because it matches the rest of the slice. T
8181
```rust
8282
fn foo(words: &[&str]) {
8383
match words {
84-
// ignore everything but the last element, which must be "!"
84+
// Ignore everything but the last element, which must be "!".
8585
[.., "!"] => println!("!!!"),
8686

87-
// start is a slice of everything except the last element, which must be "z"
87+
// `start` is a slice of everything except the last element, which must be "z".
8888
[start @ .., "z"] => println!("starts with: {:?}", start),
8989

90-
// end is a slice of everything but the first element, which must be "a"
90+
// `end` is a slice of everything but the first element, which must be "a".
9191
["a", end @ ..] => println!("ends with: {:?}", end),
9292

9393
rest => println!("{:?}", rest),
@@ -103,17 +103,17 @@ If you're interested in learning more, we published [a post on the Inside Rust b
103103
This release of Rust stabilizes a new macro, [`matches!`](https://doc.rust-lang.org/nightly/std/macro.matches.html). This macro accepts an expression and a pattern, and returns true if the pattern matches the expression. In other words:
104104

105105
```rust
106-
// with the match keyword
106+
// Using a match expression:
107107
match self.partial_cmp(other) {
108108
Some(Less) => true,
109109
_ => false,
110110
}
111111

112-
// with the matches! macro
112+
// Using the `matches!` macro:
113113
matches!(self.partial_cmp(other), Some(Less))
114114
```
115115

116-
You can also use features like `|` patterns and `if` clauses:
116+
You can also use features like `|` patterns and `if` guards:
117117

118118
```rust
119119
let foo = 'f';
@@ -127,7 +127,7 @@ assert!(matches!(bar, Some(x) if x > 2));
127127

128128
In Rust 2018, we [removed the need for `extern crate`](https://doc.rust-lang.org/stable/edition-guide/rust-2018/module-system/path-clarity.html#no-more-extern-crate). But procedural macros were a bit special, and so when you were writing a procedural macro, you still needed to say `extern crate proc_macro;`.
129129

130-
In this release, [you no longer need this line when working with the 2018 edition; you can use `use` like any other crate][cargo/7700]. Given that most projects will already have a line similar to `use proc_macro::TokenStream;`, this change will mean that you can delete the `extern crate proc_macro;` line and your code will still work. This change is small, but brings procedural macros closer to regular code.
130+
In this release, if you are using Cargo, [you no longer need this line when working with the 2018 edition; you can use `use` like any other crate][cargo/7700]. Given that most projects will already have a line similar to `use proc_macro::TokenStream;`, this change will mean that you can delete the `extern crate proc_macro;` line and your code will still work. This change is small, but brings procedural macros closer to regular code.
131131

132132
### Libraries
133133

@@ -172,4 +172,4 @@ Apple is no longer supporting 32-bit targets, and so, neither are we. They have
172172

173173
## Contributors to 1.42.0
174174

175-
Many people came together to create Rust 1.42.0. We couldn't have done it without all of you. [Thanks!](https://thanks.rust-lang.org/rust/1.42.0/)
175+
Many people came together to create Rust 1.42.0. We couldn't have done it without all of you. [Thanks!](https://thanks.rust-lang.org/rust/1.42.0/)

0 commit comments

Comments
 (0)