File tree Expand file tree Collapse file tree 2 files changed +12
-10
lines changed
exercises/19_smart_pointers
solutions/19_smart_pointers Expand file tree Collapse file tree 2 files changed +12
-10
lines changed Original file line number Diff line number Diff line change @@ -45,8 +45,9 @@ mod tests {
45
45
#[ test]
46
46
fn owned_no_mutation ( ) {
47
47
// 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.
50
51
let vec = vec ! [ 0 , 1 , 2 ] ;
51
52
let mut input = Cow :: from ( vec) ;
52
53
abs_all ( & mut input) ;
@@ -56,9 +57,9 @@ mod tests {
56
57
57
58
#[ test]
58
59
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.
62
63
let vec = vec ! [ -1 , 0 , 1 ] ;
63
64
let mut input = Cow :: from ( vec) ;
64
65
abs_all ( & mut input) ;
Original file line number Diff line number Diff line change @@ -45,8 +45,9 @@ mod tests {
45
45
#[ test]
46
46
fn owned_no_mutation ( ) {
47
47
// 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.
50
51
let vec = vec ! [ 0 , 1 , 2 ] ;
51
52
let mut input = Cow :: from ( vec) ;
52
53
abs_all ( & mut input) ;
@@ -56,9 +57,9 @@ mod tests {
56
57
57
58
#[ test]
58
59
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.
62
63
let vec = vec ! [ -1 , 0 , 1 ] ;
63
64
let mut input = Cow :: from ( vec) ;
64
65
abs_all ( & mut input) ;
You can’t perform that action at this time.
0 commit comments