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!!
-
-
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.
Show this thread -
This is how e.g. Rc, and Mutex(Guard) work -- custom behavior around *any* wrapper type!
Show this thread
End of conversation
New conversation -
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.