Skip to content

Commit 319143a

Browse files
committed
Apply clippy suggesions
Mostly just adding #[must_use]
1 parent 9aacf0e commit 319143a

File tree

3 files changed

+14
-2
lines changed

3 files changed

+14
-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: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -203,6 +203,7 @@ where
203203
/// intrinsics are not available. The closure **must** search for
204204
/// the same bytes as in the array.
205205
#[allow(unused_variables)]
206+
#[must_use]
206207
pub fn new(bytes: [u8; 16], len: i32, fallback: F) -> Self {
207208
Bytes {
208209
#[cfg(any(jetscii_sse4_2 = "yes", jetscii_sse4_2 = "maybe"))]
@@ -222,6 +223,7 @@ where
222223
// the fallback at all, so it will be dropped in this function.
223224
#[doc(hidden)]
224225
#[allow(unused_variables)]
226+
#[must_use]
225227
pub const fn new_const(bytes: [u8; 16], len: i32, fallback: F) -> Self
226228
where
227229
F: Copy,
@@ -239,6 +241,7 @@ where
239241

240242
/// Searches the slice for the first matching byte in the set.
241243
#[inline]
244+
#[must_use]
242245
pub fn find(&self, haystack: &[u8]) -> Option<usize> {
243246
dispatch! {
244247
simd: unsafe { self.simd.find(haystack) },
@@ -268,6 +271,7 @@ where
268271
/// ### Panics
269272
///
270273
/// - If you provide a non-ASCII byte.
274+
#[must_use]
271275
pub fn new(chars: [u8; 16], len: i32, fallback: F) -> Self {
272276
for &b in &chars {
273277
assert!(b < 128, "Cannot have non-ASCII bytes");
@@ -281,6 +285,7 @@ where
281285
// (thus, have no destructor). If we _know_ we're using sse4.2, we don't use
282286
// the fallback at all, so it will be dropped in this function.
283287
#[doc(hidden)]
288+
#[must_use]
284289
pub const fn new_const(chars: [u8; 16], len: i32, fallback: F) -> Self
285290
where
286291
F: Copy,
@@ -295,6 +300,7 @@ where
295300

296301
/// Searches the string for the first matching ASCII byte in the set.
297302
#[inline]
303+
#[must_use]
298304
pub fn find(&self, haystack: &str) -> Option<usize> {
299305
self.0.find(haystack.as_bytes())
300306
}
@@ -313,6 +319,7 @@ pub struct ByteSubstring<'a> {
313319
}
314320

315321
impl<'a> ByteSubstring<'a> {
322+
#[must_use]
316323
pub const fn new(needle: &'a [u8]) -> Self {
317324
ByteSubstring {
318325
#[cfg(any(jetscii_sse4_2 = "yes", jetscii_sse4_2 = "maybe"))]
@@ -324,6 +331,7 @@ impl<'a> ByteSubstring<'a> {
324331
}
325332

326333
#[cfg(feature = "pattern")]
334+
#[must_use]
327335
fn needle_len(&self) -> usize {
328336
dispatch! {
329337
simd: self.simd.needle_len(),
@@ -333,6 +341,7 @@ impl<'a> ByteSubstring<'a> {
333341

334342
/// Searches the slice for the first occurence of the subslice.
335343
#[inline]
344+
#[must_use]
336345
pub fn find(&self, haystack: &[u8]) -> Option<usize> {
337346
dispatch! {
338347
simd: unsafe { self.simd.find(haystack) },
@@ -348,17 +357,20 @@ pub type ByteSubstringConst = ByteSubstring<'static>;
348357
pub struct Substring<'a>(ByteSubstring<'a>);
349358

350359
impl<'a> Substring<'a> {
360+
#[must_use]
351361
pub const fn new(needle: &'a str) -> Self {
352362
Substring(ByteSubstring::new(needle.as_bytes()))
353363
}
354364

355365
#[cfg(feature = "pattern")]
366+
#[must_use]
356367
fn needle_len(&self) -> usize {
357368
self.0.needle_len()
358369
}
359370

360371
/// Searches the string for the first occurence of the substring.
361372
#[inline]
373+
#[must_use]
362374
pub fn find(&self, haystack: &str) -> Option<usize> {
363375
self.0.find(haystack.as_bytes())
364376
}

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)