atomic_ref2/
into_option_arc.rs

1use std::sync::Arc;
2
3pub trait IntoOptionArc<T> {
4    fn into_option_arc(self) -> Option<Arc<T>>;
5}
6
7impl<T> IntoOptionArc<T> for T {
8    fn into_option_arc(self) -> Option<Arc<Self>> {
9        Some(Arc::new(self))
10    }
11}
12
13impl<T> IntoOptionArc<T> for Arc<T> {
14    fn into_option_arc(self) -> Option<Self> {
15        Some(self)
16    }
17}
18
19impl<T> IntoOptionArc<T> for Option<Arc<T>> {
20    fn into_option_arc(self) -> Self {
21        self
22    }
23}