1use std::{
4 ffi::{OsStr, OsString},
5 rc::Rc,
6 sync::Arc,
7};
8
9use crate::{ffi::IOsStr, mow_os_str::MowOsStr, IStr, MowStr};
10
11#[doc(hidden)]
13pub unsafe trait Interned {}
14#[doc(hidden)]
16pub unsafe trait Muterned {}
17
18pub trait Interning {
20 type Outern: Interned;
21
22 fn interned(self) -> Self::Outern;
24}
25
26pub trait Muterning {
28 type Outern: Muterned;
29
30 fn muterned(self) -> Self::Outern;
32}
33
34impl Interning for char {
35 type Outern = IStr;
36
37 fn interned(self) -> Self::Outern {
38 IStr::from(self)
39 }
40}
41
42impl Interning for &str {
43 type Outern = IStr;
44
45 fn interned(self) -> Self::Outern {
46 IStr::new(self)
47 }
48}
49
50impl Interning for Box<str> {
51 type Outern = IStr;
52
53 fn interned(self) -> Self::Outern {
54 IStr::from_boxed(self)
55 }
56}
57
58impl Interning for Arc<str> {
59 type Outern = IStr;
60
61 fn interned(self) -> Self::Outern {
62 IStr::from_arc(self)
63 }
64}
65
66impl Interning for Rc<str> {
67 type Outern = IStr;
68
69 fn interned(self) -> Self::Outern {
70 IStr::from_rc(self)
71 }
72}
73
74impl Interning for String {
75 type Outern = IStr;
76
77 fn interned(self) -> Self::Outern {
78 IStr::from_string(self)
79 }
80}
81
82impl Interning for IStr {
83 type Outern = IStr;
84
85 fn interned(self) -> Self::Outern {
86 self
87 }
88}
89
90impl Interning for MowStr {
91 type Outern = MowStr;
92
93 fn interned(mut self) -> Self::Outern {
94 self.intern();
95 self
96 }
97}
98
99impl Interning for &OsStr {
100 type Outern = IOsStr;
101
102 fn interned(self) -> Self::Outern {
103 IOsStr::new(self)
104 }
105}
106
107impl Interning for OsString {
108 type Outern = IOsStr;
109
110 fn interned(self) -> Self::Outern {
111 IOsStr::from_os_string(self)
112 }
113}
114
115impl Interning for Box<OsStr> {
116 type Outern = IOsStr;
117
118 fn interned(self) -> Self::Outern {
119 IOsStr::from_boxed(self)
120 }
121}
122
123impl Interning for Arc<OsStr> {
124 type Outern = IOsStr;
125
126 fn interned(self) -> Self::Outern {
127 IOsStr::from_arc(self)
128 }
129}
130
131impl Interning for Rc<OsStr> {
132 type Outern = IOsStr;
133
134 fn interned(self) -> Self::Outern {
135 IOsStr::from_rc(self)
136 }
137}
138
139impl Interning for IOsStr {
140 type Outern = IOsStr;
141
142 fn interned(self) -> Self::Outern {
143 self
144 }
145}
146
147impl Interning for MowOsStr {
148 type Outern = MowOsStr;
149
150 fn interned(mut self) -> Self::Outern {
151 self.intern();
152 self
153 }
154}
155
156impl Muterning for char {
157 type Outern = MowStr;
158
159 fn muterned(self) -> Self::Outern {
160 MowStr::new_mut(self)
161 }
162}
163
164impl Muterning for &str {
165 type Outern = MowStr;
166
167 fn muterned(self) -> Self::Outern {
168 MowStr::new_mut(self)
169 }
170}
171
172impl Muterning for Box<str> {
173 type Outern = MowStr;
174
175 fn muterned(self) -> Self::Outern {
176 MowStr::from_string_mut(self.to_string())
177 }
178}
179
180impl Muterning for Arc<str> {
181 type Outern = MowStr;
182
183 fn muterned(self) -> Self::Outern {
184 MowStr::from_string_mut(self.to_string())
185 }
186}
187
188impl Muterning for Rc<str> {
189 type Outern = MowStr;
190
191 fn muterned(self) -> Self::Outern {
192 MowStr::from_string_mut(self.to_string())
193 }
194}
195
196impl Muterning for String {
197 type Outern = MowStr;
198
199 fn muterned(self) -> Self::Outern {
200 MowStr::from_string_mut(self)
201 }
202}
203
204impl Muterning for IStr {
205 type Outern = MowStr;
206
207 fn muterned(self) -> Self::Outern {
208 MowStr::from_string_mut(self.to_string())
209 }
210}
211
212impl Muterning for MowStr {
213 type Outern = MowStr;
214
215 fn muterned(mut self) -> Self::Outern {
216 self.to_mut();
217 self
218 }
219}
220
221impl Muterning for &OsStr {
222 type Outern = MowOsStr;
223
224 fn muterned(self) -> Self::Outern {
225 MowOsStr::new_mut(self)
226 }
227}
228
229impl Muterning for OsString {
230 type Outern = MowOsStr;
231
232 fn muterned(self) -> Self::Outern {
233 MowOsStr::from_os_string_mut(self)
234 }
235}
236
237impl Muterning for Box<OsStr> {
238 type Outern = MowOsStr;
239
240 fn muterned(self) -> Self::Outern {
241 MowOsStr::from_os_string_mut(self.to_os_string())
242 }
243}
244
245impl Muterning for Arc<OsStr> {
246 type Outern = MowOsStr;
247
248 fn muterned(self) -> Self::Outern {
249 MowOsStr::from_os_string_mut(self.to_os_string())
250 }
251}
252
253impl Muterning for Rc<OsStr> {
254 type Outern = MowOsStr;
255
256 fn muterned(self) -> Self::Outern {
257 MowOsStr::from_os_string_mut(self.to_os_string())
258 }
259}
260
261impl Muterning for IOsStr {
262 type Outern = MowOsStr;
263
264 fn muterned(self) -> Self::Outern {
265 MowOsStr::from_i_os_str(self)
266 }
267}
268
269impl Muterning for MowOsStr {
270 type Outern = MowOsStr;
271
272 fn muterned(self) -> Self::Outern {
273 self
274 }
275}