pub trait Dupe {
#[must_use]
fn dupe(&self) -> Self;
}
macro_rules! impl_dupe_as_clone {
($t:ty => $($g:ident),* $(,)?) => {
impl<$($g),*> Dupe for $t {
#[inline]
fn dupe(&self) -> Self {
self.clone()
}
}
};
($($t:ty => ($($g:ident),* $(,)?)),* $(,)?) => {
$(impl_dupe_as_clone!($t => $($g),*);)*
};
}
impl_dupe_as_clone! {
bytes::Bytes => (),
http::header::HeaderValue => (),
http::uri::Authority => (),
http::uri::Scheme => (),
http::uri::PathAndQuery => (),
http::Uri => (),
std::sync::Arc<T> => (T),
tokio::sync::mpsc::Sender<T> => (T),
tokio::sync::mpsc::UnboundedSender<T> => (T),
tokio::sync::broadcast::Sender<T> => (T),
}
#[cfg(loom)]
impl_dupe_as_clone! {
loom::sync::Arc<T> => (T),
}