In the section "Lifetime Branding" of Chapter 04 (PhantomData types that carry no data):
https://microsoft.github.io/RustTraining/rust-patterns-book/ch04-phantomdata-types-that-carry-no-data.html#lifetime-branding
the provided example code does not compile as written.
Observed behavior
Compiling the example leads to a borrow checker error:
Compiling lphantom v0.1.0 (/home/lighthouse/lr/lphantom)
error[E0502]: cannot borrow `arena1` as immutable because it is also borrowed as mutable
--> src/main.rs:39:20
|
33 | let handle1 = arena1.alloc("hello".to_string());
| ------ mutable borrow occurs here
...
39 | println!("{}", arena1.get(handle1)); // ✅
| ^^^^^^ ------- mutable borrow later used here
| |
| immutable borrow occurs here
For more information about this error, try `rustc --explain E0502`.
error: could not compile `lphantom` (bin "lphantom") due to 1 previous error
In the section "Lifetime Branding" of Chapter 04 (PhantomData types that carry no data):
https://microsoft.github.io/RustTraining/rust-patterns-book/ch04-phantomdata-types-that-carry-no-data.html#lifetime-branding
the provided example code does not compile as written.
Observed behavior
Compiling the example leads to a borrow checker error: