Skip to content

Commit 05a98da

Browse files
authored
Merge pull request #1326 from rossmacarthur/fix/unit-called-nil
Do not use "nil" to refer to `()`
2 parents 25482c1 + 2876b85 commit 05a98da

File tree

2 files changed

+14
-14
lines changed

2 files changed

+14
-14
lines changed

src/custom_types/structs.md

+2-2
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ struct Person<'a> {
1616
}
1717
1818
// A unit struct
19-
struct Nil;
19+
struct Unit;
2020
2121
// A tuple struct
2222
struct Pair(i32, f32);
@@ -70,7 +70,7 @@ fn main() {
7070
};
7171
7272
// Instantiate a unit struct
73-
let _nil = Nil;
73+
let _unit = Unit;
7474
7575
// Instantiate a tuple struct
7676
let pair = Pair(1, 0.1);

src/trait/clone.md

+12-12
Original file line numberDiff line numberDiff line change
@@ -1,30 +1,30 @@
11
# Clone
22

33
When dealing with resources, the default behavior is to transfer them during
4-
assignments or function calls. However, sometimes we need to make a
4+
assignments or function calls. However, sometimes we need to make a
55
copy of the resource as well.
66

7-
The [`Clone`][clone] trait helps us do exactly this. Most commonly, we can
7+
The [`Clone`][clone] trait helps us do exactly this. Most commonly, we can
88
use the `.clone()` method defined by the `Clone` trait.
99

1010
```rust,editable
1111
// A unit struct without resources
1212
#[derive(Debug, Clone, Copy)]
13-
struct Nil;
13+
struct Unit;
1414
1515
// A tuple struct with resources that implements the `Clone` trait
1616
#[derive(Clone, Debug)]
1717
struct Pair(Box<i32>, Box<i32>);
1818
1919
fn main() {
20-
// Instantiate `Nil`
21-
let nil = Nil;
22-
// Copy `Nil`, there are no resources to move
23-
let copied_nil = nil;
20+
// Instantiate `Unit`
21+
let unit = Unit;
22+
// Copy `Unit`, there are no resources to move
23+
let copied_unit = unit;
2424
25-
// Both `Nil`s can be used independently
26-
println!("original: {:?}", nil);
27-
println!("copy: {:?}", copied_nil);
25+
// Both `Unit`s can be used independently
26+
println!("original: {:?}", unit);
27+
println!("copy: {:?}", copied_unit);
2828
2929
// Instantiate `Pair`
3030
let pair = Pair(Box::new(1), Box::new(2));
@@ -37,7 +37,7 @@ fn main() {
3737
// Error! `pair` has lost its resources
3838
//println!("original: {:?}", pair);
3939
// TODO ^ Try uncommenting this line
40-
40+
4141
// Clone `moved_pair` into `cloned_pair` (resources are included)
4242
let cloned_pair = moved_pair.clone();
4343
// Drop the original pair using std::mem::drop
@@ -52,4 +52,4 @@ fn main() {
5252
}
5353
```
5454

55-
[clone]: https://doc.rust-lang.org/std/clone/trait.Clone.html
55+
[clone]: https://doc.rust-lang.org/std/clone/trait.Clone.html

0 commit comments

Comments
 (0)