What are the exact rules of auto-dereferencing in Rust?
Hello everyone! I started learning Rust recently and I'm constantly confused about when and how the compiler automatically dereferences references. For example, I see that you can call the `len()` method on `&String`, even though `len()` is defined for `String`. Or you can pass `&i32` to a function that expects `i32`, and Rust will dereference it automatically?\n\nHere are examples that confuse me:\n\n```rust\nfn main() {\n let s = String::from("hello");\n let r = &s;\n println!("{}", r.len()); // Works! But r is &String, not String\n\n let x = 5;\n let y = &x;\n let z = *y; // Here I understand — need explicit dereference\n println!("{}", z);\n\n // And here — why does it work?\n let v = vec![1, 2, 3];\n let v_ref = &v;\n println!("{}", v_ref[0]); // v_ref is &Vec, but we use index