Skip to content

Commit 731603e

Browse files
committed
nursery warnings as well
1 parent aa69c38 commit 731603e

File tree

1 file changed

+14
-14
lines changed

1 file changed

+14
-14
lines changed

src/lib.rs

+14-14
Original file line numberDiff line numberDiff line change
@@ -40,12 +40,12 @@ const OWN_FLAG: usize = !LEN_MASK;
4040
impl<'a> MownStr<'a> {
4141
#[deprecated = "use from_ref instead. This method caused confusion with FromStr::from_str."]
4242
#[must_use]
43-
pub const fn from_str(other: &'a str) -> MownStr<'a> {
43+
pub const fn from_str(other: &'a str) -> Self {
4444
Self::from_ref(other)
4545
}
4646

4747
#[must_use]
48-
pub const fn from_ref(other: &'a str) -> MownStr<'a> {
48+
pub const fn from_ref(other: &'a str) -> Self {
4949
assert!(other.len() <= LEN_MASK);
5050
// NB: The only 'const' constructor for NonNull is new_unchecked
5151
// so we need an unsafe block.
@@ -84,7 +84,7 @@ impl<'a> MownStr<'a> {
8484
}
8585

8686
#[inline]
87-
fn real_len(&self) -> usize {
87+
const fn real_len(&self) -> usize {
8888
self.xlen & LEN_MASK
8989
}
9090

@@ -128,7 +128,7 @@ impl<'a> Drop for MownStr<'a> {
128128
}
129129

130130
impl<'a> Clone for MownStr<'a> {
131-
fn clone(&self) -> MownStr<'a> {
131+
fn clone(&self) -> Self {
132132
if self.is_owned() {
133133
Box::<str>::from(&**self).into()
134134
} else {
@@ -144,13 +144,13 @@ impl<'a> Clone for MownStr<'a> {
144144
// Construct a MownStr
145145

146146
impl<'a> From<&'a str> for MownStr<'a> {
147-
fn from(other: &'a str) -> MownStr<'a> {
147+
fn from(other: &'a str) -> Self {
148148
Self::from_ref(other)
149149
}
150150
}
151151

152152
impl<'a> From<Box<str>> for MownStr<'a> {
153-
fn from(other: Box<str>) -> MownStr<'a> {
153+
fn from(other: Box<str>) -> Self {
154154
let len = other.len();
155155
assert!(len <= LEN_MASK);
156156
let addr = Box::leak(other).as_mut_ptr();
@@ -169,13 +169,13 @@ impl<'a> From<Box<str>> for MownStr<'a> {
169169
}
170170

171171
impl<'a> From<String> for MownStr<'a> {
172-
fn from(other: String) -> MownStr<'a> {
172+
fn from(other: String) -> Self {
173173
other.into_boxed_str().into()
174174
}
175175
}
176176

177177
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 {
179179
match other {
180180
Cow::Borrowed(r) => r.into(),
181181
Cow::Owned(s) => s.into(),
@@ -219,21 +219,21 @@ impl<'a> hash::Hash for MownStr<'a> {
219219
}
220220

221221
impl<'a> PartialEq for MownStr<'a> {
222-
fn eq(&self, other: &MownStr<'a>) -> bool {
222+
fn eq(&self, other: &Self) -> bool {
223223
**self == **other
224224
}
225225
}
226226

227227
impl<'a> Eq for MownStr<'a> {}
228228

229229
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> {
231231
Some(self.cmp(other))
232232
}
233233
}
234234

235235
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 {
237237
self.deref().cmp(&**other)
238238
}
239239
}
@@ -281,19 +281,19 @@ impl<'a> fmt::Display for MownStr<'a> {
281281
// Converting
282282

283283
impl<'a> From<MownStr<'a>> for Box<str> {
284-
fn from(other: MownStr<'a>) -> Box<str> {
284+
fn from(other: MownStr<'a>) -> Self {
285285
other.to()
286286
}
287287
}
288288

289289
impl<'a> From<MownStr<'a>> for String {
290-
fn from(other: MownStr<'a>) -> String {
290+
fn from(other: MownStr<'a>) -> Self {
291291
other.to()
292292
}
293293
}
294294

295295
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 {
297297
if other.is_owned() {
298298
other.to::<String>().into()
299299
} else {

0 commit comments

Comments
 (0)