Skip to content

Commit 45f637c

Browse files
committed
Apply clippy suggesions
Mostly just adding #[must_use]
1 parent 8a87509 commit 45f637c

File tree

3 files changed

+8
-2
lines changed

3 files changed

+8
-2
lines changed

src/fallback.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ where
1414
}
1515

1616
pub fn find(&self, haystack: &[u8]) -> Option<usize> {
17-
haystack.iter().cloned().position(&self.fallback)
17+
haystack.iter().copied().position(&self.fallback)
1818
}
1919
}
2020

src/lib.rs

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -275,6 +275,7 @@ pub struct ByteSubstring<'a> {
275275
}
276276

277277
impl<'a> ByteSubstring<'a> {
278+
#[must_use]
278279
pub const fn new(needle: &'a [u8]) -> Self {
279280
ByteSubstring {
280281
#[cfg(any(jetscii_sse4_2 = "yes", jetscii_sse4_2 = "maybe"))]
@@ -286,6 +287,7 @@ impl<'a> ByteSubstring<'a> {
286287
}
287288

288289
#[cfg(feature = "pattern")]
290+
#[must_use]
289291
const fn needle_len(&self) -> usize {
290292
dispatch! {
291293
simd: self.simd.needle_len(),
@@ -295,6 +297,7 @@ impl<'a> ByteSubstring<'a> {
295297

296298
/// Searches the slice for the first occurence of the subslice.
297299
#[inline]
300+
#[must_use]
298301
pub fn find(&self, haystack: &[u8]) -> Option<usize> {
299302
dispatch! {
300303
simd: unsafe { self.simd.find(haystack) },
@@ -310,17 +313,20 @@ pub type ByteSubstringConst = ByteSubstring<'static>;
310313
pub struct Substring<'a>(ByteSubstring<'a>);
311314

312315
impl<'a> Substring<'a> {
316+
#[must_use]
313317
pub const fn new(needle: &'a str) -> Self {
314318
Substring(ByteSubstring::new(needle.as_bytes()))
315319
}
316320

317321
#[cfg(feature = "pattern")]
322+
#[must_use]
318323
const fn needle_len(&self) -> usize {
319324
self.0.needle_len()
320325
}
321326

322327
/// Searches the string for the first occurence of the substring.
323328
#[inline]
329+
#[must_use]
324330
pub fn find(&self, haystack: &str) -> Option<usize> {
325331
self.0.find(haystack.as_bytes())
326332
}

src/simd.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,7 @@ where
4141
packed.cmpestri(haystack.as_ptr(), haystack.len() as i32)
4242
}
4343

44-
/// The PCMPxSTRx instructions always read 16 bytes worth of
44+
/// The `PCMPxSTRx` instructions always read 16 bytes worth of
4545
/// data. Although the instructions handle unaligned memory access
4646
/// just fine, they might attempt to read off the end of a page
4747
/// and into a protected area.

0 commit comments

Comments
 (0)