Declare two variable both i32 1

⚓ rust    📅 2025-05-06    👤 surdeus    👁️ 5      

surdeus

Warning

This post was published 56 days ago. The information described in this article may have changed.
fn main() {
    let i1 = &1;
    let i2 = &1;
    if i1 == i2 {
        println!("immutable borrow is the same reference");
    }
}

so, there is only one i32 and i1 and i2 is the same reference, they both reference to the same 1?
is there any rust document explain this?

6 posts - 6 participants

Read full topic

🏷️ rust_feed