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

+2-2
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

+1-1
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

+2-2
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

+4-4
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

+3-3
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

+1-1
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

+1-1
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

+1-1
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

+4-4
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

+1-1
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

src/doc/book/custom-allocators.md

+8-8
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,7 @@ which allocator is in use is done simply by linking to the desired allocator:
4141
extern crate alloc_system;
4242
4343
fn main() {
44-
let a = Box::new(4); // allocates from the system allocator
44+
let a = Box::new(4); // Allocates from the system allocator.
4545
println!("{}", a);
4646
}
4747
```
@@ -57,7 +57,7 @@ uses jemalloc by default one would write:
5757
extern crate alloc_jemalloc;
5858
5959
pub fn foo() {
60-
let a = Box::new(4); // allocates from jemalloc
60+
let a = Box::new(4); // Allocates from jemalloc.
6161
println!("{}", a);
6262
}
6363
# fn main() {}
@@ -72,11 +72,11 @@ crate which implements the allocator API (e.g. the same as `alloc_system` or
7272
annotated version of `alloc_system`
7373

7474
```rust,no_run
75-
# // only needed for rustdoc --test down below
75+
# // Only needed for rustdoc --test down below.
7676
# #![feature(lang_items)]
7777
// The compiler needs to be instructed that this crate is an allocator in order
7878
// to realize that when this is linked in another allocator like jemalloc should
79-
// not be linked in
79+
// not be linked in.
8080
#![feature(allocator)]
8181
#![allocator]
8282
@@ -85,7 +85,7 @@ annotated version of `alloc_system`
8585
// however, can use all of libcore.
8686
#![no_std]
8787
88-
// Let's give a unique name to our custom allocator
88+
// Let's give a unique name to our custom allocator:
8989
#![crate_name = "my_allocator"]
9090
#![crate_type = "rlib"]
9191
@@ -126,15 +126,15 @@ pub extern fn __rust_reallocate(ptr: *mut u8, _old_size: usize, size: usize,
126126
#[no_mangle]
127127
pub extern fn __rust_reallocate_inplace(_ptr: *mut u8, old_size: usize,
128128
_size: usize, _align: usize) -> usize {
129-
old_size // this api is not supported by libc
129+
old_size // This api is not supported by libc.
130130
}
131131
132132
#[no_mangle]
133133
pub extern fn __rust_usable_size(size: usize, _align: usize) -> usize {
134134
size
135135
}
136136
137-
# // only needed to get rustdoc to test this
137+
# // Only needed to get rustdoc to test this:
138138
# fn main() {}
139139
# #[lang = "panic_fmt"] fn panic_fmt() {}
140140
# #[lang = "eh_personality"] fn eh_personality() {}
@@ -149,7 +149,7 @@ After we compile this crate, it can be used as follows:
149149
extern crate my_allocator;
150150
151151
fn main() {
152-
let a = Box::new(8); // allocates memory via our custom allocator crate
152+
let a = Box::new(8); // Allocates memory via our custom allocator crate.
153153
println!("{}", a);
154154
}
155155
```

src/doc/book/deref-coercions.md

+8-8
Original file line numberDiff line numberDiff line change
@@ -33,13 +33,13 @@ automatically coerce to a `&T`. Here’s an example:
3333

3434
```rust
3535
fn foo(s: &str) {
36-
// borrow a string for a second
36+
// Borrow a string for a second.
3737
}
3838

39-
// String implements Deref<Target=str>
39+
// String implements Deref<Target=str>.
4040
let owned = "Hello".to_string();
4141

42-
// therefore, this works:
42+
// Therefore, this works:
4343
foo(&owned);
4444
```
4545

@@ -55,14 +55,14 @@ type implements `Deref<Target=T>`, so this works:
5555
use std::rc::Rc;
5656

5757
fn foo(s: &str) {
58-
// borrow a string for a second
58+
// Borrow a string for a second.
5959
}
6060

61-
// String implements Deref<Target=str>
61+
// String implements Deref<Target=str>.
6262
let owned = "Hello".to_string();
6363
let counted = Rc::new(owned);
6464

65-
// therefore, this works:
65+
// Therefore, this works:
6666
foo(&counted);
6767
```
6868

@@ -76,10 +76,10 @@ Another very common implementation provided by the standard library is:
7676

7777
```rust
7878
fn foo(s: &[i32]) {
79-
// borrow a slice for a second
79+
// Borrow a slice for a second.
8080
}
8181

82-
// Vec<T> implements Deref<Target=[T]>
82+
// Vec<T> implements Deref<Target=[T]>.
8383
let owned = vec![1, 2, 3];
8484

8585
foo(&owned);

src/doc/book/documentation.md

+2-2
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@ code. You can use documentation comments for this purpose:
2828
/// let five = Rc::new(5);
2929
/// ```
3030
pub fn new(value: T) -> Rc<T> {
31-
// implementation goes here
31+
// Implementation goes here.
3232
}
3333
```
3434

@@ -483,7 +483,7 @@ you have a module in `foo.rs`, you'll often open its code and see this:
483483
```rust
484484
//! A module for using `foo`s.
485485
//!
486-
//! The `foo` module contains a lot of useful functionality blah blah blah
486+
//! The `foo` module contains a lot of useful functionality blah blah blah...
487487
```
488488

489489
### Crate documentation

src/doc/book/drop.md

+2-2
Original file line numberDiff line numberDiff line change
@@ -18,9 +18,9 @@ impl Drop for HasDrop {
1818
fn main() {
1919
let x = HasDrop;
2020

21-
// do stuff
21+
// Do stuff.
2222

23-
} // x goes out of scope here
23+
} // `x` goes out of scope here.
2424
```
2525

2626
When `x` goes out of scope at the end of `main()`, the code for `Drop` will

src/doc/book/enums.md

+1-1
Original file line numberDiff line numberDiff line change
@@ -51,7 +51,7 @@ possible variants:
5151

5252
```rust,ignore
5353
fn process_color_change(msg: Message) {
54-
let Message::ChangeColor(r, g, b) = msg; // compile-time error
54+
let Message::ChangeColor(r, g, b) = msg; // This causes a compile-time error.
5555
}
5656
```
5757

0 commit comments

Comments
 (0)