moxie
moxie copied to clipboard
`moxie::Key` is and isn't a smart pointer
Two API guidelines are in conflict for Key
:
- Smart pointers do not add inherent methods (C-SMART-PTR)
- Only smart pointers implement Deref and DerefMut (C-DEREF)
Key implements Deref (but not DerefMut), and it adds inherent methods. Its deref impl is useful for sharing the "current state" with app logic as it is.
Key shouldn't implement Deref -- it has footguns! Notably it's pretty easy to rely on the deref behavior immediately after having updated the key, only to find it hasn't actually changed.