@@ -203,6 +203,7 @@ where
203
203
/// intrinsics are not available. The closure **must** search for
204
204
/// the same bytes as in the array.
205
205
#[ allow( unused_variables) ]
206
+ #[ must_use]
206
207
pub fn new ( bytes : [ u8 ; 16 ] , len : i32 , fallback : F ) -> Self {
207
208
Bytes {
208
209
#[ cfg( any( jetscii_sse4_2 = "yes" , jetscii_sse4_2 = "maybe" ) ) ]
@@ -222,6 +223,7 @@ where
222
223
// the fallback at all, so it will be dropped in this function.
223
224
#[ doc( hidden) ]
224
225
#[ allow( unused_variables) ]
226
+ #[ must_use]
225
227
pub const fn new_const ( bytes : [ u8 ; 16 ] , len : i32 , fallback : F ) -> Self
226
228
where
227
229
F : Copy ,
@@ -239,6 +241,7 @@ where
239
241
240
242
/// Searches the slice for the first matching byte in the set.
241
243
#[ inline]
244
+ #[ must_use]
242
245
pub fn find ( & self , haystack : & [ u8 ] ) -> Option < usize > {
243
246
dispatch ! {
244
247
simd: unsafe { self . simd. find( haystack) } ,
@@ -268,6 +271,7 @@ where
268
271
/// ### Panics
269
272
///
270
273
/// - If you provide a non-ASCII byte.
274
+ #[ must_use]
271
275
pub fn new ( chars : [ u8 ; 16 ] , len : i32 , fallback : F ) -> Self {
272
276
for & b in & chars {
273
277
assert ! ( b < 128 , "Cannot have non-ASCII bytes" ) ;
@@ -281,6 +285,7 @@ where
281
285
// (thus, have no destructor). If we _know_ we're using sse4.2, we don't use
282
286
// the fallback at all, so it will be dropped in this function.
283
287
#[ doc( hidden) ]
288
+ #[ must_use]
284
289
pub const fn new_const ( chars : [ u8 ; 16 ] , len : i32 , fallback : F ) -> Self
285
290
where
286
291
F : Copy ,
@@ -295,6 +300,7 @@ where
295
300
296
301
/// Searches the string for the first matching ASCII byte in the set.
297
302
#[ inline]
303
+ #[ must_use]
298
304
pub fn find ( & self , haystack : & str ) -> Option < usize > {
299
305
self . 0 . find ( haystack. as_bytes ( ) )
300
306
}
@@ -313,6 +319,7 @@ pub struct ByteSubstring<'a> {
313
319
}
314
320
315
321
impl < ' a > ByteSubstring < ' a > {
322
+ #[ must_use]
316
323
pub const fn new ( needle : & ' a [ u8 ] ) -> Self {
317
324
ByteSubstring {
318
325
#[ cfg( any( jetscii_sse4_2 = "yes" , jetscii_sse4_2 = "maybe" ) ) ]
@@ -324,6 +331,7 @@ impl<'a> ByteSubstring<'a> {
324
331
}
325
332
326
333
#[ cfg( feature = "pattern" ) ]
334
+ #[ must_use]
327
335
fn needle_len ( & self ) -> usize {
328
336
dispatch ! {
329
337
simd: self . simd. needle_len( ) ,
@@ -333,6 +341,7 @@ impl<'a> ByteSubstring<'a> {
333
341
334
342
/// Searches the slice for the first occurence of the subslice.
335
343
#[ inline]
344
+ #[ must_use]
336
345
pub fn find ( & self , haystack : & [ u8 ] ) -> Option < usize > {
337
346
dispatch ! {
338
347
simd: unsafe { self . simd. find( haystack) } ,
@@ -348,17 +357,20 @@ pub type ByteSubstringConst = ByteSubstring<'static>;
348
357
pub struct Substring < ' a > ( ByteSubstring < ' a > ) ;
349
358
350
359
impl < ' a > Substring < ' a > {
360
+ #[ must_use]
351
361
pub const fn new ( needle : & ' a str ) -> Self {
352
362
Substring ( ByteSubstring :: new ( needle. as_bytes ( ) ) )
353
363
}
354
364
355
365
#[ cfg( feature = "pattern" ) ]
366
+ #[ must_use]
356
367
fn needle_len ( & self ) -> usize {
357
368
self . 0 . needle_len ( )
358
369
}
359
370
360
371
/// Searches the string for the first occurence of the substring.
361
372
#[ inline]
373
+ #[ must_use]
362
374
pub fn find ( & self , haystack : & str ) -> Option < usize > {
363
375
self . 0 . find ( haystack. as_bytes ( ) )
364
376
}
0 commit comments