1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
mod better;
mod orig;
mod sealed;
use alloc::borrow::ToOwned;
pub trait Cow<'a, T>: Clone
where
T: ?Sized + ToOwned,
{
fn borrowed(b: &'a T) -> Self;
fn owned(o: T::Owned) -> Self;
fn is_borrowed(&self) -> bool;
fn is_owned(&self) -> bool;
fn make_ref(&self) -> &T;
fn into_owned(self) -> T::Owned;
}
pub trait Dairy<'a>: ToOwned + sealed::Sealed {
type Cow: Cow<'a, Self>;
}
impl<'a> Dairy<'a> for str {
type Cow = better::Cow<'a, Self>;
}
impl<'a, T: Clone + 'a> Dairy<'a> for [T] {
type Cow = better::Cow<'a, Self>;
}
#[cfg(feature = "std")]
impl<'a> Dairy<'a> for std::ffi::CStr {
type Cow = better::Cow<'a, Self>;
}
#[cfg(unix)]
#[cfg(feature = "std")]
impl<'a> Dairy<'a> for std::ffi::OsStr {
type Cow = better::Cow<'a, Self>;
}
#[cfg(windows)]
#[cfg(feature = "std")]
impl<'a> Dairy<'a> for std::ffi::OsStr {
type Cow = alloc::borrow::Cow<'a, Self>;
}
#[cfg(unix)]
#[cfg(feature = "std")]
impl<'a> Dairy<'a> for std::path::Path {
type Cow = better::Cow<'a, Self>;
}
#[cfg(windows)]
#[cfg(feature = "std")]
impl<'a> Dairy<'a> for std::path::Path {
type Cow = alloc::borrow::Cow<'a, Self>;
}