@@ -40,12 +40,12 @@ const OWN_FLAG: usize = !LEN_MASK;
40
40
impl < ' a > MownStr < ' a > {
41
41
#[ deprecated = "use from_ref instead. This method caused confusion with FromStr::from_str." ]
42
42
#[ must_use]
43
- pub const fn from_str ( other : & ' a str ) -> MownStr < ' a > {
43
+ pub const fn from_str ( other : & ' a str ) -> Self {
44
44
Self :: from_ref ( other)
45
45
}
46
46
47
47
#[ must_use]
48
- pub const fn from_ref ( other : & ' a str ) -> MownStr < ' a > {
48
+ pub const fn from_ref ( other : & ' a str ) -> Self {
49
49
assert ! ( other. len( ) <= LEN_MASK ) ;
50
50
// NB: The only 'const' constructor for NonNull is new_unchecked
51
51
// so we need an unsafe block.
@@ -84,7 +84,7 @@ impl<'a> MownStr<'a> {
84
84
}
85
85
86
86
#[ inline]
87
- fn real_len ( & self ) -> usize {
87
+ const fn real_len ( & self ) -> usize {
88
88
self . xlen & LEN_MASK
89
89
}
90
90
@@ -128,7 +128,7 @@ impl<'a> Drop for MownStr<'a> {
128
128
}
129
129
130
130
impl < ' a > Clone for MownStr < ' a > {
131
- fn clone ( & self ) -> MownStr < ' a > {
131
+ fn clone ( & self ) -> Self {
132
132
if self . is_owned ( ) {
133
133
Box :: < str > :: from ( & * * self ) . into ( )
134
134
} else {
@@ -144,13 +144,13 @@ impl<'a> Clone for MownStr<'a> {
144
144
// Construct a MownStr
145
145
146
146
impl < ' a > From < & ' a str > for MownStr < ' a > {
147
- fn from ( other : & ' a str ) -> MownStr < ' a > {
147
+ fn from ( other : & ' a str ) -> Self {
148
148
Self :: from_ref ( other)
149
149
}
150
150
}
151
151
152
152
impl < ' a > From < Box < str > > for MownStr < ' a > {
153
- fn from ( other : Box < str > ) -> MownStr < ' a > {
153
+ fn from ( other : Box < str > ) -> Self {
154
154
let len = other. len ( ) ;
155
155
assert ! ( len <= LEN_MASK ) ;
156
156
let addr = Box :: leak ( other) . as_mut_ptr ( ) ;
@@ -169,13 +169,13 @@ impl<'a> From<Box<str>> for MownStr<'a> {
169
169
}
170
170
171
171
impl < ' a > From < String > for MownStr < ' a > {
172
- fn from ( other : String ) -> MownStr < ' a > {
172
+ fn from ( other : String ) -> Self {
173
173
other. into_boxed_str ( ) . into ( )
174
174
}
175
175
}
176
176
177
177
impl < ' a > From < Cow < ' a , str > > for MownStr < ' a > {
178
- fn from ( other : Cow < ' a , str > ) -> MownStr < ' a > {
178
+ fn from ( other : Cow < ' a , str > ) -> Self {
179
179
match other {
180
180
Cow :: Borrowed ( r) => r. into ( ) ,
181
181
Cow :: Owned ( s) => s. into ( ) ,
@@ -219,21 +219,21 @@ impl<'a> hash::Hash for MownStr<'a> {
219
219
}
220
220
221
221
impl < ' a > PartialEq for MownStr < ' a > {
222
- fn eq ( & self , other : & MownStr < ' a > ) -> bool {
222
+ fn eq ( & self , other : & Self ) -> bool {
223
223
* * self == * * other
224
224
}
225
225
}
226
226
227
227
impl < ' a > Eq for MownStr < ' a > { }
228
228
229
229
impl < ' a > PartialOrd for MownStr < ' a > {
230
- fn partial_cmp ( & self , other : & MownStr < ' a > ) -> Option < std:: cmp:: Ordering > {
230
+ fn partial_cmp ( & self , other : & Self ) -> Option < std:: cmp:: Ordering > {
231
231
Some ( self . cmp ( other) )
232
232
}
233
233
}
234
234
235
235
impl < ' a > Ord for MownStr < ' a > {
236
- fn cmp ( & self , other : & MownStr < ' a > ) -> std:: cmp:: Ordering {
236
+ fn cmp ( & self , other : & Self ) -> std:: cmp:: Ordering {
237
237
self . deref ( ) . cmp ( & * * other)
238
238
}
239
239
}
@@ -281,19 +281,19 @@ impl<'a> fmt::Display for MownStr<'a> {
281
281
// Converting
282
282
283
283
impl < ' a > From < MownStr < ' a > > for Box < str > {
284
- fn from ( other : MownStr < ' a > ) -> Box < str > {
284
+ fn from ( other : MownStr < ' a > ) -> Self {
285
285
other. to ( )
286
286
}
287
287
}
288
288
289
289
impl < ' a > From < MownStr < ' a > > for String {
290
- fn from ( other : MownStr < ' a > ) -> String {
290
+ fn from ( other : MownStr < ' a > ) -> Self {
291
291
other. to ( )
292
292
}
293
293
}
294
294
295
295
impl < ' a > From < MownStr < ' a > > for Cow < ' a , str > {
296
- fn from ( other : MownStr < ' a > ) -> Cow < ' a , str > {
296
+ fn from ( other : MownStr < ' a > ) -> Self {
297
297
if other. is_owned ( ) {
298
298
other. to :: < String > ( ) . into ( )
299
299
} else {
0 commit comments