macro_rules! try_to_clone {
(&$value:expr) => { ... };
($value:expr) => { ... };
}Expand description
Tries to clone a value.
Accepts either value or &value.
Conversion order:
- Types implementing
Copyare copied. - Types implementing
Cloneare cloned. - All other types return
None.
ยงExamples
let value = String::from("hello");
assert_eq!(phlow::try_to_clone!(value.clone()), Some(String::from("hello")));
assert_eq!(phlow::try_to_clone!(&value), Some(String::from("hello")));