1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21
//! The traits module provides extended implementations of standard traits.
use crate::compat::boxed::Box;
use crate::error::Result;
/// Clone trait for async structs.
#[async_trait]
pub trait AsyncTryClone: Sized {
/// Try cloning a object and return an `Err` in case of failure.
async fn async_try_clone(&self) -> Result<Self>;
}
#[async_trait]
impl<D> AsyncTryClone for D
where
D: Clone + Sync,
{
async fn async_try_clone(&self) -> Result<Self> {
Ok(self.clone())
}
}