summaryrefslogtreecommitdiff
path: root/solutions/19_smart_pointers/cow1.rs
diff options
context:
space:
mode:
authormo8it <mo8it@proton.me>2024-07-07 17:03:00 +0200
committermo8it <mo8it@proton.me>2024-07-07 17:03:00 +0200
commit9d7b973a62d3c0181be386752d72fa0722fe6135 (patch)
tree111bb203fe0c0e5e5ebbc8926cca60ca2d9b9849 /solutions/19_smart_pointers/cow1.rs
parenta5f221aa39196b00cb12425ba9f6ed5500ae5790 (diff)
Improve the comments in cow1
Diffstat (limited to 'solutions/19_smart_pointers/cow1.rs')
-rw-r--r--solutions/19_smart_pointers/cow1.rs11
1 files changed, 6 insertions, 5 deletions
diff --git a/solutions/19_smart_pointers/cow1.rs b/solutions/19_smart_pointers/cow1.rs
index 0a21a91..461143b 100644
--- a/solutions/19_smart_pointers/cow1.rs
+++ b/solutions/19_smart_pointers/cow1.rs
@@ -45,8 +45,9 @@ mod tests {
#[test]
fn owned_no_mutation() {
// We can also pass `vec` without `&` so `Cow` owns it directly. In this
- // case, no mutation occurs and thus also no clone. But the result is
- // still owned because it was never borrowed or mutated.
+ // case, no mutation occurs (all numbers are already absolute) and thus
+ // also no clone. But the result is still owned because it was never
+ // borrowed or mutated.
let vec = vec![0, 1, 2];
let mut input = Cow::from(vec);
abs_all(&mut input);
@@ -56,9 +57,9 @@ mod tests {
#[test]
fn owned_mutation() {
- // Of course this is also the case if a mutation does occur. In this
- // case, the call to `to_mut()` in the `abs_all` function returns a
- // reference to the same data as before.
+ // Of course this is also the case if a mutation does occur (not all
+ // numbers are absolute). In this case, the call to `to_mut()` in the
+ // `abs_all` function returns a reference to the same data as before.
let vec = vec![-1, 0, 1];
let mut input = Cow::from(vec);
abs_all(&mut input);