Mistakes with Rust smart pointers: when Deref goes wrong

https://www.fuzzypixelz.com/blog/deref-confusion/

Unusually high astonishment by Rust standards

19 points · 2 comments · view on lemmy.world

2 Comments

words_number@programming.dev · 4 pts · 3y

Interesting read, thanks :)

Btw. on my browsr (fennec on android) some angle brackets and types seem to be missing in the code examples. Might be an html-escape issue.

Anders429@lemmy.world · 1 pts · 3y

Good article. I don't know if I would consider this newtype to be a smart pointer, and I think that's where the issues creep in. But I've definitely seen people suggest implementing Deref for newtypes on sites like stackoverflow, and IMO it's not entirely obvious when you should actually implement Deref.