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
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
use crate::{IStr, MowStr};

pub unsafe trait Interned {}
pub unsafe trait Muterned {}

pub trait Interning {
    type Outern: Interned;

    fn interned(self) -> Self::Outern;
}

pub trait Muterning {
    type Outern: Muterned;

    fn muterned(self) -> Self::Outern;
}

impl Interning for &str {
    type Outern = IStr;

    fn interned(self) -> Self::Outern {
        IStr::from(self)
    }
}

impl Interning for Box<str> {
    type Outern = IStr;

    fn interned(self) -> Self::Outern {
        IStr::from(self)
    }
}

impl Interning for String {
    type Outern = IStr;

    fn interned(self) -> Self::Outern {
        IStr::from(self)
    }
}

impl Interning for IStr {
    type Outern = IStr;

    fn interned(self) -> Self::Outern {
        self
    }
}

impl Interning for MowStr {
    type Outern = MowStr;

    fn interned(mut self) -> Self::Outern {
        self.intern();
        self
    }
}

impl Muterning for &str {
    type Outern = MowStr;

    fn muterned(self) -> Self::Outern {
        MowStr::new_mut(self)
    }
}

impl Muterning for Box<str> {
    type Outern = MowStr;

    fn muterned(self) -> Self::Outern {
        MowStr::from_boxed_str_mut(self)
    }
}

impl Muterning for String {
    type Outern = MowStr;

    fn muterned(self) -> Self::Outern {
        MowStr::from_string_mut(self)
    }
}

impl Muterning for IStr {
    type Outern = MowStr;

    fn muterned(self) -> Self::Outern {
        MowStr::from_istr_mut(self)
    }
}

impl Muterning for MowStr {
    type Outern = MowStr;

    fn muterned(mut self) -> Self::Outern {
        self.to_mut();
        self
    }
}