[][src]Function show_notes::e019::demonstrate_mut_cow

pub fn demonstrate_mut_cow(_point: &mut BJustClonePoint)

What if we need a mutable reference to the wrapped type?


We can get a mutable reference to the wrapped item, even if the wrapped item isn't itself mutable, as long as it's Clone-able. In this case, we're making a copy---this is explicit in the to_mut() call. If the underlying item isn't mutably accessible, we'll just get a mutable copy.

let mut a_point: Cow<BJustClonePoint> = Cow::Owned(BJustClonePoint::origin());