Skip to content

Commit 90484a2

Browse files
authored
fix comment in 'Clone to stasify borrow checker' (#291)
1 parent bcf1a7a commit 90484a2

File tree

1 file changed

+4
-4
lines changed

1 file changed

+4
-4
lines changed

anti_patterns/borrow_clone.md

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -17,14 +17,14 @@ let mut x = 5;
1717
// Borrow `x` -- but clone it first
1818
let y = &mut (x.clone());
1919

20-
// perform some action on the borrow to prevent rust from optimizing this
21-
//out of existence
22-
*y += 1;
23-
2420
// without the x.clone() two lines prior, this line would fail on compile as
2521
// x has been borrowed
2622
// thanks to x.clone(), x was never borrowed, and this line will run.
2723
println!("{}", x);
24+
25+
// perform some action on the borrow to prevent rust from optimizing this
26+
//out of existence
27+
*y += 1;
2828
```
2929

3030
## Motivation

0 commit comments

Comments
 (0)