Skip to content

Commit 9d7b973

Browse files
committed
Improve the comments in cow1
1 parent a5f221a commit 9d7b973

File tree

2 files changed

+12
-10
lines changed

2 files changed

+12
-10
lines changed

exercises/19_smart_pointers/cow1.rs

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -45,8 +45,9 @@ mod tests {
4545
#[test]
4646
fn owned_no_mutation() {
4747
// We can also pass `vec` without `&` so `Cow` owns it directly. In this
48-
// case, no mutation occurs and thus also no clone. But the result is
49-
// still owned because it was never borrowed or mutated.
48+
// case, no mutation occurs (all numbers are already absolute) and thus
49+
// also no clone. But the result is still owned because it was never
50+
// borrowed or mutated.
5051
let vec = vec![0, 1, 2];
5152
let mut input = Cow::from(vec);
5253
abs_all(&mut input);
@@ -56,9 +57,9 @@ mod tests {
5657

5758
#[test]
5859
fn owned_mutation() {
59-
// Of course this is also the case if a mutation does occur. In this
60-
// case, the call to `to_mut()` in the `abs_all` function returns a
61-
// reference to the same data as before.
60+
// Of course this is also the case if a mutation does occur (not all
61+
// numbers are absolute). In this case, the call to `to_mut()` in the
62+
// `abs_all` function returns a reference to the same data as before.
6263
let vec = vec![-1, 0, 1];
6364
let mut input = Cow::from(vec);
6465
abs_all(&mut input);

solutions/19_smart_pointers/cow1.rs

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -45,8 +45,9 @@ mod tests {
4545
#[test]
4646
fn owned_no_mutation() {
4747
// We can also pass `vec` without `&` so `Cow` owns it directly. In this
48-
// case, no mutation occurs and thus also no clone. But the result is
49-
// still owned because it was never borrowed or mutated.
48+
// case, no mutation occurs (all numbers are already absolute) and thus
49+
// also no clone. But the result is still owned because it was never
50+
// borrowed or mutated.
5051
let vec = vec![0, 1, 2];
5152
let mut input = Cow::from(vec);
5253
abs_all(&mut input);
@@ -56,9 +57,9 @@ mod tests {
5657

5758
#[test]
5859
fn owned_mutation() {
59-
// Of course this is also the case if a mutation does occur. In this
60-
// case, the call to `to_mut()` in the `abs_all` function returns a
61-
// reference to the same data as before.
60+
// Of course this is also the case if a mutation does occur (not all
61+
// numbers are absolute). In this case, the call to `to_mut()` in the
62+
// `abs_all` function returns a reference to the same data as before.
6263
let vec = vec![-1, 0, 1];
6364
let mut input = Cow::from(vec);
6465
abs_all(&mut input);

0 commit comments

Comments
 (0)