Path for a reference to a vec's item?
⚓ Rust 📅 2025-05-08 👤 surdeus 👁️ 16In this code:
fn main() {
let a: Vec<i32> = vec![1,2,3];
let b: &i32 = &a[2];
println!("{a:?}, {b}");
}
Should I think of b as path number 2 in the image below, or paths number 1a and 1b (although in this case I'm unsure how it directs to 1b unless it remembers the offset, somehow ?
If you want to edit the image maybe this can be forked from the source.
5 posts - 2 participants
🏷️ rust_feed
