This commit is contained in:
MarcoIeni 2022-01-14 23:21:05 +00:00
parent 74eaa27fc6
commit 2ae0b1b1a0
4 changed files with 10 additions and 10 deletions

View File

@ -163,14 +163,14 @@ let mut x = 5;
// Borrow `x` -- but clone it first
let y = &mut (x.clone());
// perform some action on the borrow to prevent rust from optimizing this
//out of existence
*y += 1;
// without the x.clone() two lines prior, this line would fail on compile as
// x has been borrowed
// thanks to x.clone(), x was never borrowed, and this line will run.
println!("{}", x);
// perform some action on the borrow to prevent rust from optimizing this
//out of existence
*y += 1;
<span class="boring">}
</span></code></pre></pre>
<h2 id="motivation"><a class="header" href="#motivation">Motivation</a></h2>

View File

@ -3043,14 +3043,14 @@ let mut x = 5;
// Borrow `x` -- but clone it first
let y = &amp;mut (x.clone());
// perform some action on the borrow to prevent rust from optimizing this
//out of existence
*y += 1;
// without the x.clone() two lines prior, this line would fail on compile as
// x has been borrowed
// thanks to x.clone(), x was never borrowed, and this line will run.
println!(&quot;{}&quot;, x);
// perform some action on the borrow to prevent rust from optimizing this
//out of existence
*y += 1;
<span class="boring">}
</span></code></pre></pre>
<h2 id="motivation-17"><a class="header" href="#motivation-17">Motivation</a></h2>

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long