E0503 Cannot Use Fix
A mutable borrow of a value is still live - and still has a use ahead of it - at the line where the value itself is used. This guide separates five shapes that produce E0503 and matches each one to the change that ends the overlap: finish with the borrow first, or take the copy the use needs before the borrow exists.
Written November 23, 2026 · Tested with Rust 1.99.1 · 27 min read
- The rule underneath: a value cannot be used while a mutable borrow of it is still live
- How to read the diagnostic
- The first failure: a variable read in an expression while it is mutably borrowed
- The second failure: a value passed by value while it is mutably borrowed
Written November 23, 2026
Tested with Rust 1.99.1
What this guide is
Error E0503 is a blocked use. The error codes index defines it in one line: a value was used after it was mutably borrowed. The use itself is an ordinary one - reading the value in an arithmetic expression, passing it by value to a function, calling a method that takes it by value, reading one of its fields, or reading one of its elements - and most of the values in this guide are Copy, so the use does not even move anything. What blocks it is a mutable borrow: some &mut reference to that same value, to one of its fields, or to one of its elements was created earlier, is still live at the use line, and is used again afterward. A mutable borrow promises its holder exclusive access to the value, so the compiler refuses any direct use of the value until the borrow is over.
The five forms in this guide each reproduce E0503 with a small, complete program, and each reaches the blocked use by a different route. A plain variable read in an arithmetic expression while a &mut of it is live. The same variable passed by value to a function. A method call that takes the value as its receiver. A struct field read while that same field is mutably borrowed. And an array element read while a different element of the same array is mutably borrowed. In each family the failing program is small, the full compiler output is shown, and the fix ends the overlap rather than fighting it: the borrow's last use moves before the use, so the borrow is already over when the value is used directly.
Four neighboring codes are not E0503 and are worked only in the traps and the decision summary. When the second operation is itself a mutable borrow of the same value, the error is E0499, cannot borrow as mutable more than once at a time. When the second operation is a borrow with a different mutability - reading a vector element through an index, which borrows the vector immutably, while a &mut of it is live - the error is E0502, cannot borrow as immutable because it is also borrowed as mutable. When the operation on a non-Copy value is a move rather than a use, the error is E0505, cannot move out because it is borrowed. And when the operation replaces the value instead of reading it, the error is E0506, cannot assign to a borrowed value. E0503 is the remaining case: the value stays where it is, nothing new is borrowed, and the direct use alone conflicts with the live mutable borrow.
Build every program in this guide with rustc --edition 2021. In the compiler transcripts below, the file names are the bare names shown on the command line.
The rule underneath: a value cannot be used while a mutable borrow of it is still live
A mutable reference is an exclusive borrow. The Rust Book chapter on references and borrowing states the restriction directly: if you have a mutable reference to a value, you can have no other references to that value. A reference refers to a value owned by some other variable, without taking ownership of it. The mutable borrow's holder is allowed to change the value through the reference, and that permission is only sound if nothing else can observe or use the value at the same time - a direct read of the value in the middle of the borrow could see it in whatever state the borrow's holder has left it in, and a copy taken at that moment would freeze a state the holder is about to change. So while the mutable borrow is live, the compiler closes the value itself to direct use: no reads in expressions, no by-value passes, no by-value method calls, and no reads of the borrowed place's fields or elements.
What makes a borrow "still live" is use, not scope alone. The Book states the scope rule directly: a reference's scope starts from where it is introduced and continues through the last time that reference is used. This is the non-lexical-lifetimes behavior every fix in this guide relies on. A borrow whose last use is on the line before the direct use is already over at the use, and the identical use compiles. A borrow with one more use waiting below - a println!, a return, a later read - is live across the use, and the use fails. That is why the diagnostic always shows three points, not one: where the value was mutably borrowed, where the use occurs, and where the borrow is later used. Delete or move that later use and the error goes with it.
The rule follows the borrowed place, at the granularity the compiler can prove. Borrowing one field of a struct mutably blocks using that field - the fourth family shows the header naming p.a, not p - but a read of a different, disjoint field of the same struct is a different place, and the traps section shows it compiling while the first field's borrow is live. Arrays are tracked more coarsely: a mutable borrow of one element registers as a borrow of a[_], the array's elements as a class, so reading any element - even a different one - is a use of the borrowed place, as the fifth family shows. The header tells you which granularity your case got: a plain variable name, a field path, or the [_] element form.
One fix in the error codes index works before the borrow rather than after it. The index's second fix clones the value before borrowing it, so the later code uses the clone - a separate value the borrow does not cover - while the borrow of the original runs to its last use undisturbed. The traps section shows that shape with a string: the clone is taken first, the mutable borrow second, and a use of the clone compiles between them. That fix is only needed when the borrow and the use genuinely have to interleave; where the borrow's last use can simply move up, reordering is free and the clone is waste.
How to read the diagnostic
The header names the used place and the reason in one line: "cannot use" the place "because it was mutably borrowed". Read the place first, because it tells you what the blocked use tried to touch - value is a whole variable, p.a is one field of a struct, a[_] is an element of an array. Three labeled lines then map the overlap. The line ending "x is borrowed here" marks where the live mutable borrow was created. The caret line repeats the use with the label "use of borrowed x" - that caret is the line to fix, and it sits on the expression that used the value, whether that is an operand, a function argument, a method receiver, a field, or an index. And a later line is marked "borrow later used here" - that use is the reason the borrow is still live, and it is the line every fix in this guide moves, removes, or works around.
There is no help: rewrite in an E0503 diagnostic, unlike the move and clone errors: the compiler does not propose a changed expression, because the expression is fine - it is the timing that is wrong. The fix is always temporal or structural: end the borrow before the use (move its last use up, or confine it to a scope block), take the copy the use needs before the borrow exists, or split the places so the use and the borrow no longer overlap. Reading the three labels in order - borrowed, used, borrow used again - tells you which of those is available: if the borrow's later use can move, reorder; if the use's value can be captured early, copy it out first; if neither, the borrow and the use have to be separated by a scope or a redesign of the places involved.
The first failure: a variable read in an expression while it is mutably borrowed
borrow mutably borrows value, the next line reads value in an arithmetic expression, and the println! after that still reads through borrow. That later read is what keeps the borrow alive across the use:
fn main() {
let mut value = 3;
let borrow = &mut value;
let sum = value + 1;
println!("{}, {}", sum, borrow);
}
$ rustc --edition 2021 fail_scalar.rs -o fail_scalar
error[E0503]: cannot use `value` because it was mutably borrowed
--> fail_scalar.rs:4:15
|
3 | let borrow = &mut value;
| ---------- `value` is borrowed here
4 | let sum = value + 1;
| ^^^^^ use of borrowed `value`
5 | println!("{}, {}", sum, borrow);
| ------ borrow later used here
error: aborting due to 1 previous error
For more information about this error, try `rustc --explain E0503`.
This is the shape in the error codes index's own example - a mutable borrow on one side of the use, and a use of the borrow on the other side. The caret is under the operand value alone, because the addition is not the problem; reading the borrowed value to feed it is. The fix is the index's first fix - finish using the borrow before the next use of the value:
fn main() {
let mut value = 3;
let borrow = &mut value;
println!("{}", borrow);
let sum = value + 1;
println!("{}", sum);
}
$ rustc --edition 2021 fix_scalar.rs -o fix_scalar
$ ./fix_scalar
3
4
The output is 3, the borrowed value read through the borrow while it was live, then 4, the sum computed after the borrow ended. Nothing about the borrow changed - it is the same &mut value - only its last use moved above the use of value.
The second failure: a value passed by value while it is mutably borrowed
show takes its argument by value, so calling show(value) uses value - for a u32 that use is a copy, not a move, but a use is all E0503 needs. borrow mutably borrows value on the line before the call, and the println! after the call still reads through borrow:
fn show(x: u32) {
println!("show {}", x);
}
fn main() {
let mut value = 3;
let borrow = &mut value;
show(value);
println!("{}", borrow);
}
$ rustc --edition 2021 fail_by_value.rs -o fail_by_value
error[E0503]: cannot use `value` because it was mutably borrowed
--> fail_by_value.rs:8:10
|
7 | let borrow = &mut value;
| ---------- `value` is borrowed here
8 | show(value);
| ^^^^^ use of borrowed `value`
9 | println!("{}", borrow);
| ------ borrow later used here
error: aborting due to 1 previous error
For more information about this error, try `rustc --explain E0503`.
The caret sits on the argument, because passing by value is the use - the function never gets to run. Contrast the non-Copy version of this shape in the traps: passing a String by value is a move, not a copy-use, and the same layout fails as E0505 instead. The fix here is the first family's fix at call scale: the borrow's last use moves above the call, and the call then uses a value nobody is borrowing:
fn show(x: u32) {
println!("show {}", x);
}
fn main() {
let mut value = 3;
let borrow = &mut value;
println!("{}", borrow);
show(value);
}
$ rustc --edition 2021 fix_by_value.rs -o fix_by_value
$ ./fix_by_value
3
show 3
The output is 3, read through the borrow, then show 3 from inside the function that received its copy after the borrow ended. Where the function's signature is yours to change, taking &u32 or &mut u32 instead also removes the direct use - but that trades this error for the borrow rules at the call, and is only a fix when the caller and the borrow can be sequenced there instead.
The third failure: a method call that takes the value by value
saturating_mul takes its receiver by value, so value.saturating_mul(2) uses value in exactly the way the second family did, with no function call in sight. borrow mutably borrows value, the method call reads it as a receiver, and the println! after that still reads through borrow:
fn main() {
let mut value = 3u32;
let borrow = &mut value;
let doubled = value.saturating_mul(2);
println!("{}, {}", doubled, borrow);
}
$ rustc --edition 2021 fail_method.rs -o fail_method
error[E0503]: cannot use `value` because it was mutably borrowed
--> fail_method.rs:4:19
|
3 | let borrow = &mut value;
| ---------- `value` is borrowed here
4 | let doubled = value.saturating_mul(2);
| ^^^^^ use of borrowed `value`
5 | println!("{}, {}", doubled, borrow);
| ------ borrow later used here
error: aborting due to 1 previous error
For more information about this error, try `rustc --explain E0503`.
The caret is under the receiver alone, not the whole call - the argument 2 is irrelevant, and the method name is not what is blocked; using the value as the receiver is. This is the family that hides in real code, because a method call does not look like a use of the variable the way an operand or an argument does. Whether a method call triggers E0503 depends on its receiver: a by-value receiver is a use, while a method that takes &self or &mut self is a borrow, and a borrow conflict is reported as E0502 or E0499 instead - the traps section shows that split on a vector. The fix is the same reorder:
fn main() {
let mut value = 3u32;
let borrow = &mut value;
println!("{}", borrow);
let doubled = value.saturating_mul(2);
println!("{}", doubled);
}
$ rustc --edition 2021 fix_method_value.rs -o fix_method_value
$ ./fix_method_value
3
6
The output is 3, read through the borrow, then 6, the doubled value computed once the borrow was over. The method, its argument, and its result are unchanged - only the borrow's last use moved above the call.
The fourth failure: a struct field used while that same field is mutably borrowed
Here the borrow and the use meet on one field. a_ref mutably borrows p.a, the next line reads p.a as part of a sum, and the final println! still reads a_ref:
struct Pair {
a: u32,
b: u32,
}
fn main() {
let mut p = Pair { a: 1, b: 2 };
let a_ref = &mut p.a;
let total = p.a + p.b;
println!("{}, {}", a_ref, total);
}
$ rustc --edition 2021 fail_struct_field_use.rs -o fail_struct_field_use
error[E0503]: cannot use `p.a` because it was mutably borrowed
--> fail_struct_field_use.rs:9:17
|
8 | let a_ref = &mut p.a;
| -------- `p.a` is borrowed here
9 | let total = p.a + p.b;
| ^^^ use of borrowed `p.a`
10 | println!("{}, {}", a_ref, total);
| ----- borrow later used here
error: aborting due to 1 previous error
For more information about this error, try `rustc --explain E0503`.
The header names the field path p.a, and the caret sits on p.a alone - the p.b read on the same line is legal, and the diagnostic does not flag it. That precision is the field-granularity rule at work: the borrow is of the field, so the use of the field is what is blocked. The fix is the first family's fix at field scale: the borrow's last use moves above the sum:
struct Pair {
a: u32,
b: u32,
}
fn main() {
let mut p = Pair { a: 1, b: 2 };
let a_ref = &mut p.a;
println!("{}", a_ref);
let total = p.a + p.b;
println!("{}", total);
}
$ rustc --edition 2021 fix_struct_field_use.rs -o fix_struct_field_use
$ ./fix_struct_field_use
1
3
The output is 1, the borrowed field read before the sum, then 3 - the sum of both fields read after the borrow ended. The b field was never borrowed and never blocked; only the borrowed field's use had to wait, and ending that one borrow is enough to free it.
The fifth failure: an array element used while another element is mutably borrowed
first mutably borrows a[0] - one element - the next line reads a[1], a different element, and the println! after that still reads through first. Unlike the struct family, the disjoint element does not save the use:
fn main() {
let mut a = [1, 2, 3];
let first = &mut a[0];
let second = a[1];
println!("{}, {}", first, second);
}
$ rustc --edition 2021 fail_array_elem.rs -o fail_array_elem
error[E0503]: cannot use `a[_]` because it was mutably borrowed
--> fail_array_elem.rs:4:18
|
3 | let first = &mut a[0];
| --------- `a[_]` is borrowed here
4 | let second = a[1];
| ^^^^ use of borrowed `a[_]`
5 | println!("{}, {}", first, second);
| ----- borrow later used here
error: aborting due to 1 previous error
For more information about this error, try `rustc --explain E0503`.
The header names neither a[0] nor a[1] - it names a[_], the elements of the array as a class, and both labels use that same form. An indexed borrow cannot be tracked to one constant element the way a field borrow is tracked to one named field, so the borrow covers every element, and a use of any element overlaps it. Reading two elements on one line produces one error per element read, not a new code - the single read here is what keeps this transcript to one error. The fix is again the reorder: the borrow's last use moves above the element read:
fn main() {
let mut a = [1, 2, 3];
let first = &mut a[0];
println!("{}", first);
let second = a[1];
println!("{}", second);
}
$ rustc --edition 2021 fix_array_elem.rs -o fix_array_elem
$ ./fix_array_elem
1
2
The output is 1, the borrowed element read while its borrow was live, then 2, the second element read after it. Where two elements genuinely have to be worked on at once, the shape built for that is a split of the slice - split_at_mut separates an array or slice into disjoint mutable parts the compiler can track - rather than a borrow of one element alongside direct uses of the others.
The fixes in reach order
- The borrow has a last use that can move: move it above the use - the borrow ends at its last use, and the use after it is free. This is the first reach for every family in this guide, and it costs nothing.
- The borrow is used in one self-contained block of code: confine it to a scope block
{ ... }- the borrow ends at the closing brace whatever its last use inside was, as the traps section shows. - The code only needs the value, captured early: copy it out before the borrow is taken - a plain read for a
Copytype,clone()otherwise, as the error codes index's second fix does - and use the copy while the borrow runs. - The use and the borrow touch different fields of one struct: do nothing - disjoint field places do not overlap, and the program already compiles; check the header's place path before restructuring.
- The use is of an array or slice element alongside a borrow of another: split the places with
split_at_mutor a scope, because indexed places are tracked as the whole[_]class, not per element. - The value must genuinely be used and mutably borrowed in interleaved order with no restructuring available: that is the shape interior mutability exists for - hold the value in a
CellorRefCelland borrow it at each use, accepting a runtime rule in place of the compile-time one.
Traps
- Reading a different field than the borrowed one is not E0503 at all. This program mutably borrows
p.aand readsp.bwhile the borrow is live and used afterward, and it compiles as written:
struct Pair {
a: u32,
b: u32,
}
fn main() {
let mut p = Pair { a: 1, b: 2 };
let a_ref = &mut p.a;
let b_val = p.b;
println!("{}, {}", a_ref, b_val);
}
$ rustc --edition 2021 probe_disjoint_field.rs -o probe_disjoint_field
$ ./probe_disjoint_field
1, 2
1, 2 - the borrowed field read through its borrow after the other field was read directly. Places are tracked per field, so a field borrow blocks that field and the whole value - not its sibling fields. Before restructuring around an E0503, read the place in the header: if the code you need to write uses a sibling field, it may already be legal. The array family is the contrast: elements are not named places, so no equivalent disjoint-element read exists there.
- Cloning before the borrow leaves a value the borrow does not cover. This is the error codes index's second fix, with a string: the clone is taken first, and a use of the clone compiles while the mutable borrow of the original is live:fn main() {
let mut s = String::from("hello");
let cloned = s.clone();
let r = &mut s;
let len = cloned.len();
println!("{}, {}", len, r);
}
$ rustc --edition 2021 probe_clone_before.rs -o probe_clone_before
$ ./probe_clone_before
5, hello
The output is 5, hello - the length of the clone, computed during the borrow, then the original read through the borrow. The cost is one cloned string, and in exchange the two values are independent: the use touches the clone, the borrow touches the original, and neither blocks the other. Take the clone after the borrow instead and the clone call itself becomes a borrow of the original - a different conflict, not this fix.
- A scope block ends a borrow even when moving a use is awkward. This is the first family with the borrow and its only use inside braces, and it compiles as written:
fn main() {
let mut value = 3;
{
let borrow = &mut value;
println!("{}", borrow);
}
let sum = value + 1;
println!("{}", sum);
}
$ rustc --edition 2021 probe_block_scope.rs -o probe_block_scope
$ ./probe_block_scope
3
4
The output is 3, read inside the block, then 4 after it. The block is the blunt form of the last-use fix: it guarantees the borrow is over at a line you choose, at the cost of an extra level of nesting - worth it when the borrow's uses are spread through code that cannot be reordered.
- A second mutable borrow is a different error. Here there is no direct use of value at all - the second operation is another &mut value, and the failure is E0499:
fn main() {
let mut value = 3;
let first = &mut value;
let second = &mut value;
println!("{}, {}", first, second);
}
$ rustc --edition 2021 probe_e0499.rs -o probe_e0499
error[E0499]: cannot borrow `value` as mutable more than once at a time
--> probe_e0499.rs:4:18
|
3 | let first = &mut value;
| ---------- first mutable borrow occurs here
4 | let second = &mut value;
| ^^^^^^^^^^ second mutable borrow occurs here
5 | println!("{}, {}", first, second);
| ----- first borrow later used here
error: aborting due to 1 previous error
For more information about this error, try `rustc --explain E0499`.
The separation is exact: in E0503 the second operation uses the value itself - a read, a copy, a by-value pass - and creates no reference. In E0499 the second operation is a borrow, and the header says so: "cannot borrow as mutable more than once". The fixes overlap (end the first borrow first), but the code in the header tells you which operation to look for in your own code. The error codes index defines E0499 as a variable borrowed as mutable more than once. - Borrowing with a different mutability is a third error, and it is the one a vector produces. Reading an element by index borrows the vector immutably, so the second family's layout with a vector in place of the scalar fails as E0502, not E0503:
fn main() {
let mut v = vec![10, 20, 30];
let borrow = &mut v;
let first = v[0];
println!("{}, {:?}", first, borrow);
}
$ rustc --edition 2021 probe_e0502.rs -o probe_e0502
error[E0502]: cannot borrow `v` as immutable because it is also borrowed as mutable
--> probe_e0502.rs:4:17
|
3 | let borrow = &mut v;
| ------ mutable borrow occurs here
4 | let first = v[0];
| ^ immutable borrow occurs here
5 | println!("{}, {:?}", first, borrow);
| ------ mutable borrow later used here
error: aborting due to 1 previous error
For more information about this error, try `rustc --explain E0502`.
Read the operation, not the intention: v[0] looks like a direct read of an element, but indexing a vector goes through a shared borrow of the whole vector, so the conflict is borrow against borrow. The scalar a[1] read in the fifth family is a use because an array index read on a Copy element is a direct place read, with no vector deref in between. The error codes index defines E0502 as a variable borrowed again with a different mutability.
- Moving a non-Copy value while it is mutably borrowed is E0505, not a use. Here the operation on s is a move - let copy = s takes the string itself - and the code changes even though the borrow is the same kind:
fn main() {
let mut s = String::from("hello");
let r = &mut s;
let copy = s;
println!("{}, {}", copy, r);
}
$ rustc --edition 2021 probe_e0505.rs -o probe_e0505
error[E0505]: cannot move out of `s` because it is borrowed
--> probe_e0505.rs:4:16
|
2 | let mut s = String::from("hello");
| ----- binding `s` declared here
3 | let r = &mut s;
| ------ borrow of `s` occurs here
4 | let copy = s;
| ^ move out of `s` occurs here
5 | println!("{}, {}", copy, r);
| - borrow later used here
|
help: consider cloning the value if the performance cost is acceptable
|
3 | let r = &mut s.clone();
| ++++++++
error: aborting due to 1 previous error
For more information about this error, try `rustc --explain E0505`.
The separation is the type: for a Copy type the same let copy = value line is a use and fails as E0503, as the first family shows; for a non-Copy type it is a move, the value would leave its place entirely, and the error is the move error. The error codes index defines E0505 as a value moved out while it was still borrowed.
- Assigning to the value while it is mutably borrowed is E0506, not a use. Here nothing reads value - the operation replaces it - and the failure carries the assignment labels instead:
fn main() {
let mut value = 3;
let borrow = &mut value;
value = 4;
println!("{}", borrow);
println!("{}", value);
}
$ rustc --edition 2021 probe_e0506.rs -o probe_e0506
error[E0506]: cannot assign to `value` because it is borrowed
--> probe_e0506.rs:4:5
|
3 | let borrow = &mut value;
| ---------- `value` is borrowed here
4 | value = 4;
| ^^^^^^^^^ `value` is assigned to here but it was already borrowed
5 | println!("{}", borrow);
| ------ borrow later used here
error: aborting due to 1 previous error
For more information about this error, try `rustc --explain E0506`.
Read the caret line's label to tell the two apart: E0503 says "use of borrowed", E0506 says "is assigned to here but it was already borrowed" - a read of the borrowed place against a replacement of it. The fix is the same reorder, but the operation to look for in your own code is an assignment, not an expression. The error codes index defines E0506 as an attempt to assign to a borrowed value.
Decision summary
- The header says "cannot use" a place "because it was mutably borrowed", with labels for where it was borrowed, the use of the borrowed place, and where the borrow is later used: a live mutable borrow blocks a direct use of an owned value - end the borrow, or take the needed copy before the borrow.
- The header names a field path,
p.a: the borrow and the blocked use meet on that field - uses of sibling fields are separate places and are not blocked. - The header names
a[_]: an element borrow covers the array's elements as a class - a use of any element is blocked, and two element reads on one line produce one error each. - The caret sits on a function argument or a method receiver: passing by value and by-value methods are uses - reorder the borrow's last use above the call, or capture the argument before the borrow.
- The header instead says "cannot borrow as mutable more than once" (E0499): the second operation is itself a mutable borrow, not a use of the value.
- The header instead says "cannot borrow as immutable because it is also borrowed as mutable" (E0502): the second operation borrows with a different mutability - an indexed vector read is the common route here.
- The header instead says "cannot move out of" the value "because it is borrowed" (E0505): the operation is a move of a non-
Copyvalue, not a copy-use of aCopyone. - The header instead says "cannot assign to" the value "because it is borrowed" (E0506): the operation replaces the value instead of reading it.
- No error at all where a use and a mutable borrow coexist: check the places - a sibling field was used, or the value used was a clone taken before the borrow.
Checklist
- The header read for the used place: a whole variable, a field path, or the
[_]element form - the use is blocked at exactly that granularity. - The three labels traced: where the value was mutably borrowed, the use line, and the later use that keeps the borrow live.
- The later use dealt with first: moved above the use, removed, confined to a scope block, or replaced by a copy or clone taken before the borrow.
- The operation classified before fixing: a direct use is E0503, a second borrow is E0499 or E0502, a move is E0505, an assignment is E0506 - the header's wording, not the intention, decides.
- Field and element granularity checked: a sibling field may already be legal, while a sibling array element is not.
- Method receivers checked: a by-value receiver is a use, a
&selfor&mut selfreceiver is a borrow conflict instead. - The fixed program run, and its output checked against what the failing program was trying to compute.
Related guides on this site
- E0505 Cannot Move Out Fix
- Fix Rust E0502 "cannot borrow as mutable because it is also borrowed as immutable" — End the First Borrow, Split the Work, or Restructure
- E0509 Cannot Move Out Fix
- E0425 Cannot Find Value Fix
Sources
- Rust, Error codes index: E0503 - the definition of the error: a value was used after it was mutably borrowed; its example reads a variable in an expression while a mutable borrow of it is held for a later print, and its fixes finish using the borrow before the next use of the value, or clone the value before borrowing it.
- The Rust Programming Language, References and Borrowing - a reference refers to a value without owning it; a mutable reference to a value excludes every other reference to that value; and a reference's scope runs from its introduction through its last use, so a borrow whose last use precedes a later use of the value no longer blocks it.
- Rust, Error codes index: E0499 - the neighboring second-borrow error: a variable was borrowed as mutable more than once; the distinction from E0503 is that the second operation is itself a mutable borrow, rather than a direct use of the value.
- Rust, Error codes index: E0502 - the neighboring mixed-mutability error: a variable already borrowed with one mutability was borrowed again with a different mutability; the distinction from E0503 is that the second operation is a borrow, as an indexed vector read is, rather than a direct use.
- Rust, Error codes index: E0505 - the neighboring move error: a value was moved out while it was still borrowed; the distinction from E0503 is that the operation moves a non-
Copyvalue out of its place, rather than using aCopyvalue in place. - Rust, Error codes index: E0506 - the neighboring assignment error: an attempt was made to assign to a borrowed value; the distinction from E0503 is that the operation replaces the borrowed place, rather than reading it.
Keep Exploring
The full Rust hub \u2014 ownership, structs and enums, async, and measured comparisons.
Every guide on the site in one list, grouped by topic.
Every browser-only checker and verifier on the site.
The C++, Python, Sysadmin, Rust, Go, and TypeScript hubs.