1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
use std::sync::Arc;

pub trait IntoOptionArc<T> {
    fn into_option_arc(self) -> Option<Arc<T>>;
}

impl<T> IntoOptionArc<T> for T {
    fn into_option_arc(self) -> Option<Arc<T>> {
        Some(Arc::new(self))
    }
}

impl<T> IntoOptionArc<T> for Arc<T> {
    fn into_option_arc(self) -> Option<Arc<T>> {
        Some(self)
    }
}

impl<T> IntoOptionArc<T> for Option<Arc<T>> {
    fn into_option_arc(self) -> Option<Arc<T>> {
        self
    }
}