1use crate::as_impl::impl_as;
2use crate::traits::{IntoOwned, ToBorrowed, ToOwned};
3use alloc::string::String;
4use core::borrow::{Borrow, BorrowMut};
5use core::cmp::Ordering;
6use core::fmt::{Debug, Display, Formatter};
7use core::hash::{Hash, Hasher};
8use core::ops::{Deref, DerefMut};
9
10#[repr(transparent)]
28pub struct AsClone<T: Clone>(pub T);
29
30impl<T: Clone> ToBorrowed<'_> for AsClone<T> {
31 #[inline(always)]
32 fn to_borrowed(&self) -> Self {
33 AsClone(self.0.clone())
34 }
35}
36
37impl<T: Clone> ToOwned for AsClone<T> {
38 type Owned = AsClone<T>;
39
40 #[inline(always)]
41 fn to_owned(&self) -> Self::Owned {
42 AsClone(self.0.clone())
43 }
44}
45
46impl<T: Clone> IntoOwned for AsClone<T> {
47 type Owned = AsClone<T>;
48
49 #[inline(always)]
50 fn into_owned(self) -> Self::Owned {
51 AsClone(self.0)
52 }
53}
54
55impl_as!(AsClone, Clone);
56
57impl From<&str> for AsClone<String> {
60 #[inline]
61 fn from(value: &str) -> Self {
62 AsClone(value.into())
63 }
64}