Explain this program. just for understanding purpose
⚓ Rust 📅 2025-10-27 👤 surdeus 👁️ 3#![allow(warnings)]
fn ok<'lt>(mut e: &'lt u32) {
let x = 4;
e = &x;
}
fn main() {
let mut z = 0;
}
Errors:
Compiling playground v0.0.1 (/playground)
error[E0597]: `x` does not live long enough
--> src/main.rs:6:9
|
3 | fn ok<'lt>(mut e: &'lt u32) {
| --- lifetime `'lt` defined here
4 |
5 | let x = 4;
| - binding `x` declared here
6 | e = &x;
| ----^^
| | |
| | borrowed value does not live long enough
| assignment requires that `x` is borrowed for `'lt`
7 | }
| - `x` dropped here while still borrowed
For more information about this error, try `rustc --explain E0597`.
error: could not compile `playground` (bin "playground") due to 1 previous error
6 posts - 3 participants
🏷️ Rust_feed