Skip to content

Commit 766f6e4

Browse files
authored
Auto merge of #37755 - polo-language:doc-punct, r=GuillaumeGomez
Improved punctuation, capitalization, and sentence structure of code snippet comments r? @GuillaumeGomez
2 parents 8289a89 + 28548db commit 766f6e4

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

41 files changed

+184
-183
lines changed

src/doc/book/associated-types.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ this:
1111
trait Graph<N, E> {
1212
fn has_edge(&self, &N, &N) -> bool;
1313
fn edges(&self, &N) -> Vec<E>;
14-
// etc
14+
// Etc.
1515
}
1616
```
1717

@@ -36,7 +36,7 @@ trait Graph {
3636

3737
fn has_edge(&self, &Self::N, &Self::N) -> bool;
3838
fn edges(&self, &Self::N) -> Vec<Self::E>;
39-
// etc
39+
// Etc.
4040
}
4141
```
4242

src/doc/book/benchmark-tests.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -110,7 +110,7 @@ computation entirely. This could be done for the example above by adjusting the
110110
# struct X;
111111
# impl X { fn iter<T, F>(&self, _: F) where F: FnMut() -> T {} } let b = X;
112112
b.iter(|| {
113-
// note lack of `;` (could also use an explicit `return`).
113+
// Note lack of `;` (could also use an explicit `return`).
114114
(0..1000).fold(0, |old, new| old ^ new)
115115
});
116116
```

src/doc/book/box-syntax-and-patterns.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,7 @@ so as to avoid copying a large data structure. For example:
3838
struct BigStruct {
3939
one: i32,
4040
two: i32,
41-
// etc
41+
// Etc.
4242
one_hundred: i32,
4343
}
4444

@@ -68,7 +68,7 @@ This is an antipattern in Rust. Instead, write this:
6868
struct BigStruct {
6969
one: i32,
7070
two: i32,
71-
// etc
71+
// Etc.
7272
one_hundred: i32,
7373
}
7474

src/doc/book/casting-between-types.md

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -106,7 +106,7 @@ from integers, and to cast between pointers to different types subject to
106106
some constraints. It is only unsafe to dereference the pointer:
107107

108108
```rust
109-
let a = 300 as *const char; // a pointer to location 300
109+
let a = 300 as *const char; // `a` is a pointer to location 300.
110110
let b = a as u32;
111111
```
112112

@@ -135,14 +135,14 @@ cast four bytes into a `u32`:
135135
```rust,ignore
136136
let a = [0u8, 0u8, 0u8, 0u8];
137137
138-
let b = a as u32; // four u8s makes a u32
138+
let b = a as u32; // Four u8s makes a u32.
139139
```
140140

141141
This errors with:
142142

143143
```text
144144
error: non-scalar cast: `[u8; 4]` as `u32`
145-
let b = a as u32; // four u8s makes a u32
145+
let b = a as u32; // Four u8s makes a u32.
146146
^~~~~~~~
147147
```
148148

@@ -170,7 +170,7 @@ fn main() {
170170
let a = [0u8, 1u8, 0u8, 0u8];
171171
let b = mem::transmute::<[u8; 4], u32>(a);
172172
println!("{}", b); // 256
173-
// or, more concisely:
173+
// Or, more concisely:
174174
let c: u32 = mem::transmute(a);
175175
println!("{}", c); // 256
176176
}

src/doc/book/choosing-your-guarantees.md

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ the following:
2525
```rust
2626
let x = Box::new(1);
2727
let y = x;
28-
// x no longer accessible here
28+
// `x` is no longer accessible here.
2929
```
3030

3131
Here, the box was _moved_ into `y`. As `x` no longer owns it, the compiler will no longer allow the
@@ -291,9 +291,9 @@ the inner data (mutably), and the lock will be released when the guard goes out
291291
```rust,ignore
292292
{
293293
let guard = mutex.lock();
294-
// guard dereferences mutably to the inner type
294+
// `guard` dereferences mutably to the inner type.
295295
*guard += 1;
296-
} // lock released when destructor runs
296+
} // Lock is released when destructor runs.
297297
```
298298

299299

src/doc/book/closures.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -116,7 +116,7 @@ let mut num = 5;
116116
{
117117
let plus_num = |x: i32| x + num;
118118

119-
} // plus_num goes out of scope, borrow of num ends
119+
} // `plus_num` goes out of scope; borrow of `num` ends.
120120

121121
let y = &mut num;
122122
```

src/doc/book/comments.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ and *doc comments*.
1010
```rust
1111
// Line comments are anything after ‘//’ and extend to the end of the line.
1212

13-
let x = 5; // this is also a line comment.
13+
let x = 5; // This is also a line comment.
1414

1515
// If you have a long explanation for something, you can put line comments next
1616
// to each other. Put a space between the // and your comment so that it’s

src/doc/book/compiler-plugins.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -48,7 +48,7 @@ extern crate rustc_plugin;
4848
use syntax::parse::token;
4949
use syntax::tokenstream::TokenTree;
5050
use syntax::ext::base::{ExtCtxt, MacResult, DummyResult, MacEager};
51-
use syntax::ext::build::AstBuilder; // trait for expr_usize
51+
use syntax::ext::build::AstBuilder; // A trait for expr_usize.
5252
use syntax::ext::quote::rt::Span;
5353
use rustc_plugin::Registry;
5454

src/doc/book/concurrency.md

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -213,10 +213,10 @@ fn main() {
213213
let mut data = Rc::new(vec![1, 2, 3]);
214214
215215
for i in 0..3 {
216-
// create a new owned reference
216+
// Create a new owned reference:
217217
let data_ref = data.clone();
218218
219-
// use it in a thread
219+
// Use it in a thread:
220220
thread::spawn(move || {
221221
data_ref[0] += i;
222222
});
@@ -390,8 +390,8 @@ use std::sync::mpsc;
390390
fn main() {
391391
let data = Arc::new(Mutex::new(0));
392392

393-
// `tx` is the "transmitter" or "sender"
394-
// `rx` is the "receiver"
393+
// `tx` is the "transmitter" or "sender".
394+
// `rx` is the "receiver".
395395
let (tx, rx) = mpsc::channel();
396396

397397
for _ in 0..10 {

src/doc/book/crates-and-modules.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -126,7 +126,7 @@ Instead of declaring a module like this:
126126

127127
```rust,ignore
128128
mod english {
129-
// contents of our module go here
129+
// Contents of our module go here.
130130
}
131131
```
132132

0 commit comments

Comments
 (0)