[][src]Module show_notes::e018

Borrow, AsRef, Deref: my head hurts now

Notes

Borrow, AsRef, and Deref are a little complicated, but they're well-worth understanding. Together, they give you tools for dealing with everything from HashMap and friends to conversions involving smart pointer types to easily using String and str or Vec and slice together.

Sponsors

(Thanks to the couple people donating who opted out of the reward tier, as well. You know who you are!)

Become a sponsor

Contact

Structs

HasAllTheImpls

Demonstrate borrowing the internal contents of the item.

NoImplsAtAll

A struct for showing that you cannot use Borrow, AsRef

Functions

coerces_via_deref

Take the same type by Deref coercion at the call site.

takes_a_borrowable

Take it implementing Borrow<[u8]>.

takes_a_reference

Take it implementing AsRef<[u8]>. Note similarity to takes_a_borrowable.