1use crate::{AsIs, BorrowAsIs, Is, IsCow, Owned, ToOwned};
2use core::borrow::Borrow;
3
4mod string;
5pub use string::StringStub;
6
7mod vec;
8pub use vec::VecStub;
9
10mod cow;
11
12macro_rules! impl_for_copy_types {
13 ($($T:ty),*$(,)?) => {
14 $(
15 impl BorrowAsIs for $T {
16 type Is = $T;
17
18 fn borrow_or_clone<B>(&self) -> IsCow<'_, B>
19 where
20 Self::Is: Borrow<B>,
21 B: ?Sized + ToOwned<Owned = Owned<Self>>
22 {
23 IsCow::Owned(*self)
24 }
25 }
26
27 impl AsIs for $T {
28 fn as_is<'a>(self) -> Is<'a, $T> {
29 Is::Owned(self)
30 }
31 }
32 )*
33 };
34}
35
36impl_for_copy_types!(
37 i8, i16, i32, i64, i128, isize, u8, u16, u32, u64, u128, usize, f32, f64, bool,
38);