'What is the difference between automatic dereferencing and Deref coercion in Rust?
As per the question, Let's say I have a following code:
struct Test {
x: i32
}
fn main() {
let test1 = Test { x: 32 }; // type inference by vscode: Test
let test2 = &test1 // type inference by vscode: &Test
let test3 = &test2 // type inference by vscode: &&Test
let explicit_ref: &Test = &test3; // This should give an error but works as I haven't implemented
//Deref trait.
}
Did I miss anything or did I misunderstand automatic dereferencing and deref coercion?
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
| Solution | Source |
|---|
