(haystack: H, needle: N)
| 1369 | /// within `haystack` if found, otherwise `None`. |
| 1370 | #[inline(always)] |
| 1371 | pub fn rfind<H, N>(haystack: H, needle: N) -> Option<usize> |
| 1372 | where |
| 1373 | H: AsRef<[u8]>, |
| 1374 | N: AsRef<[u8]>, |
| 1375 | { |
| 1376 | let haystack_ref = haystack.as_ref(); |
| 1377 | let needle_ref = needle.as_ref(); |
| 1378 | let haystack_pointer = haystack_ref.as_ptr() as _; |
| 1379 | let haystack_length = haystack_ref.len(); |
| 1380 | let needle_pointer = needle_ref.as_ptr() as _; |
| 1381 | let needle_length = needle_ref.len(); |
| 1382 | let result = unsafe { sz_rfind(haystack_pointer, haystack_length, needle_pointer, needle_length) }; |
| 1383 | |
| 1384 | if result.is_null() { |
| 1385 | None |
| 1386 | } else { |
| 1387 | Some(unsafe { result.offset_from(haystack_pointer) }.try_into().unwrap()) |
| 1388 | } |
| 1389 | } |
| 1390 | |
| 1391 | /// Finds the index of the first character in `haystack` that is also present in `needles`. |
| 1392 | /// This function is particularly useful for parsing and tokenization tasks where a set of |
no test coverage detected
searching dependent graphs…