2 ms·
To Rust's credit, 90% of the time I find I don't need to dereference much at all. For example, when you make a method call on a reference, you don't have to der
by ModernMech 5y ago
To Rust's credit, 90% of the time I find I don't need to dereference much at all. For example, when you make a method call on a reference, you don't have to dereference first, and there is no -> operator in Rust. The only time I ever really have to dereference manually in my experience is if I'm matching on some struct reference, and I want to take some field and put it in a new place.
e.g.
match &foo {
Foo{bar} => Baz{quux: *bar},
_ => (),
}
(not valid Rust but you get the point)