Skip to content

Commit 7a12201

Browse files
clippy: fix warnings under -D warnings
1 parent 288a5b8 commit 7a12201

File tree

4 files changed

+14
-14
lines changed

4 files changed

+14
-14
lines changed

src/pascal_string/mod.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -175,7 +175,7 @@ impl<const CAPACITY: usize> PascalString<CAPACITY> {
175175

176176
#[inline]
177177
pub fn pop(&mut self) -> Option<char> {
178-
let ch = self.chars().rev().next()?;
178+
let ch = self.chars().next_back()?;
179179
let newlen = self.len() - ch.len_utf8();
180180
self.len = newlen as u8;
181181
Some(ch)

src/pascal_string/with_serde.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -31,8 +31,8 @@ impl<'de, const CAPACITY: usize> Visitor<'de> for StringVisitor<CAPACITY> {
3131
where
3232
E: Error,
3333
{
34-
Ok(PascalString::try_from(v)
35-
.map_err(|TryFromStrError::TooLong| Error::invalid_length(v.len(), &self))?)
34+
PascalString::try_from(v)
35+
.map_err(|TryFromStrError::TooLong| Error::invalid_length(v.len(), &self))
3636
}
3737

3838
fn visit_bytes<E>(self, v: &[u8]) -> Result<Self::Value, E>

src/smart_string/mod.rs

Lines changed: 3 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,6 @@ impl<const N: usize> SmartString<N> {
3232
Self::Stack(PascalString::new())
3333
}
3434

35-
#[cfg(not(no_global_oom_handling))]
3635
#[inline]
3736
#[must_use]
3837
pub fn with_capacity(capacity: usize) -> Self {
@@ -59,12 +58,10 @@ impl<const N: usize> SmartString<N> {
5958
// }
6059
// }
6160

62-
#[cfg(not(no_global_oom_handling))]
6361
pub fn from_utf16(v: &[u16]) -> Result<Self, FromUtf16Error> {
6462
String::from_utf16(v).map(Self::Heap)
6563
}
6664

67-
#[cfg(not(no_global_oom_handling))]
6865
#[must_use]
6966
#[inline]
7067
pub fn from_utf16_lossy(v: &[u16]) -> Self {
@@ -138,7 +135,6 @@ impl<const N: usize> SmartString<N> {
138135
}
139136
}
140137

141-
#[cfg(not(no_global_oom_handling))]
142138
#[inline]
143139
pub fn reserve(&mut self, additional: usize) {
144140
match self {
@@ -153,7 +149,6 @@ impl<const N: usize> SmartString<N> {
153149
}
154150
}
155151

156-
#[cfg(not(no_global_oom_handling))]
157152
pub fn reserve_exact(&mut self, additional: usize) {
158153
match self {
159154
Self::Heap(s) => s.reserve_exact(additional),
@@ -206,7 +201,6 @@ impl<const N: usize> SmartString<N> {
206201
}
207202
}
208203

209-
#[cfg(not(no_global_oom_handling))]
210204
#[inline]
211205
pub fn shrink_to_fit(&mut self) {
212206
match self {
@@ -215,7 +209,6 @@ impl<const N: usize> SmartString<N> {
215209
}
216210
}
217211

218-
#[cfg(not(no_global_oom_handling))]
219212
#[inline]
220213
pub fn shrink_to(&mut self, min_capacity: usize) {
221214
match self {
@@ -224,7 +217,6 @@ impl<const N: usize> SmartString<N> {
224217
}
225218
}
226219

227-
#[cfg(not(no_global_oom_handling))]
228220
pub fn push(&mut self, ch: char) {
229221
match self {
230222
Self::Heap(s) => s.push(ch),
@@ -497,7 +489,8 @@ impl<'a, const N: usize> FromIterator<&'a str> for SmartString<N> {
497489
impl<const N: usize> fmt::Write for SmartString<N> {
498490
#[inline]
499491
fn write_str(&mut self, s: &str) -> fmt::Result {
500-
Ok(self.push_str(s))
492+
self.push_str(s);
493+
Ok(())
501494
}
502495
}
503496

@@ -508,7 +501,7 @@ impl<const N: usize, T: ops::Deref<Target = str>> ops::Add<T> for SmartString<N>
508501

509502
#[inline]
510503
fn add(mut self, rhs: T) -> Self::Output {
511-
self.push_str(&*rhs);
504+
self.push_str(&rhs);
512505
self
513506
}
514507
}

src/str_stack/mod.rs

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -40,6 +40,13 @@ impl StrStack {
4040
}
4141

4242
#[inline]
43+
/// Returns a `&str` slice without bounds checks.
44+
///
45+
/// # Safety
46+
///
47+
/// - `begin <= end`
48+
/// - `end <= self.data.len()`
49+
/// - `self.data[begin..end]` must be valid UTF-8
4350
pub unsafe fn get_unchecked(&self, begin: usize, end: usize) -> &str {
4451
let slice = unsafe { self.data.get_unchecked(begin..end) };
4552
unsafe { from_utf8_unchecked(slice) }
@@ -98,7 +105,7 @@ impl StrStack {
98105
}
99106

100107
#[inline]
101-
pub fn iter(&self) -> StrStackIter {
108+
pub fn iter(&self) -> StrStackIter<'_> {
102109
StrStackIter::new(self)
103110
}
104111
}

0 commit comments

Comments
 (0)