pub trait OptionRefExt { type Item; fn duped(self) -> Option<Self::Item> where Self::Item: Dupe; }
Extension traits on Option where it holds a ref.
Option
Like cloned, but with a Dupe constraint.
cloned
Dupe
use gazebo::prelude::*; use std::rc::Rc; let rc = Rc::new("test"); assert_eq!(Some(&rc).duped(), Some(rc)); assert_eq!(None::<&Rc<String>>.duped(), None);