I’m new to Rust and come from a C++ background.
While playing with some leet questions I found my self with this scenario
pub fn Foo(mut box: Box<MyStruct>) {
let mut ptr: &mut MyStruct;
ptr = &mut box
let mut ptr2: &mut Box<MyStruct>;
ptr2 = &mut box2}
Imagine there is a box2 for the example. The point is why both of them work, I know that one is a reference to what is inside the box and the other one to the box itself.
Is there some sort of casting, or how can I implement this “operator overloading” for my own structs, please let me know
New contributor
juanphm is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.