Okay, so I thought I knew how AsRef worked, and turns out I did, and I'm still blown away just by HOW GOOD IT IS. Y'all!! Wrapper types!!
-
Show this thread
-
rustc --explain E0515 AsRef is the answer!
1 reply 0 retweets 0 likesShow this thread -
Okay, for anyone reading along who doesn't know AsRef: Implementing AsRef allows you to make it so your type can pretend to be another type. So say, you want to add custom Drop behavior to a HashMap, you could create a wrapper implementing AsRef + Drop that wraps HashMap.
1 reply 1 retweet 7 likesShow this thread
This is how e.g. Rc, and Mutex(Guard) work -- custom behavior around *any* wrapper type!
2:34 PM - 10 Sep 2019
0 replies
0 retweets
3 likes
Loading seems to be taking a while.
Twitter may be over capacity or experiencing a momentary hiccup. Try again or visit Twitter Status for more information.