Skip to content
Snippets Groups Projects
Commit 4a2fb47a authored by Jasper Clemens Gräflich's avatar Jasper Clemens Gräflich
Browse files

Fix typo and caption

parent 7d6908dd
No related branches found
No related tags found
No related merge requests found
Pipeline #10415 passed
......@@ -459,7 +459,7 @@ v.push(v.len());
The problem lies in the second line. The first argument to \inline{push} is an \inline{&mut self}, and so the compiler implicitly borrows from \inline{v}. But then another (shared) reference is created for the call to \inline{len}. This is not allowed, and a reborrow doesn’t help either since the \inline{&mut self} is currently used. On the other hand, it is clear that the call to \inline{len} will definitely return before the unique reference is ever accessed. In fact, we can work around this problem if we save the result of \inline{v.len()} in a temporary variable, as shown in \autoref{lst:two-phase-borrow-workaround}.
\begin{lstlisting}[language=Rust, caption={Borrow twice in one method call}, label={lst:two-phase-borrow-workaround}]
\begin{lstlisting}[language=Rust, caption={Workaround for \autoref{lst:two-phase-borrow}}, label={lst:two-phase-borrow-workaround}]
let mut v = Vec::new();
let vlen = v.len();
v.push(vlen);
......@@ -469,7 +469,7 @@ This pattern—calling a method with a unique reference but also using shared re
Right now, two-phase borrowing works only for method calls where the first argument is \inline{&mut self}, and it is not resolved if generalized \ac{TPB} should even be supported. \todo{Point to Issue \#49434 for generalized TPB.}
\todo[inline]{Excourse on multi-phase borrowing}
\todo[inline]{Excurse on multi-phase borrowing}
\subsection{Loans and Regions}
\begin{enumerate}
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment