Function show_notes::e019::demonstrate_cow

source ·
pub fn demonstrate_cow(_point: &BJustClonePoint)
Expand description

The Cow type can wrap around other types and make them “reusable”.

Note that the body of this function is identical with that of the body of the example below.

§Examples

We’ll reuse the BJustClonePoint since Cow::Owned requires that the underlying type implement Clone.

let a_point = Cow::Owned(BJustClonePoint::origin());
demonstrate_cow(&a_point);

Note that even though demonstrate_cow takes a reference to BJustClonePoint, we can pass it the Cow instance; this is where the Deref implementation on Cow comes in handy.