MCPcopy Create free account
hub / github.com/ashvardanian/StringZilla / find_byteset

Function find_byteset

rust/stringzilla.rs:1405–1419  ·  view source on GitHub ↗
(haystack: H, needles: Byteset)

Source from the content-addressed store, hash-verified

1403/// `needles` within `haystack`, if found, otherwise `None`.
1404#[inline(always)]
1405pub fn find_byteset<H>(haystack: H, needles: Byteset) -> Option<usize>
1406where
1407 H: AsRef<[u8]>,
1408{
1409 let haystack_ref = haystack.as_ref();
1410 let haystack_pointer = haystack_ref.as_ptr() as _;
1411 let haystack_length = haystack_ref.len();
1412
1413 let result = unsafe { sz_find_byteset(haystack_pointer, haystack_length, &needles as *const _ as *const c_void) };
1414 if result.is_null() {
1415 None
1416 } else {
1417 Some(unsafe { result.offset_from(haystack_pointer) }.try_into().unwrap())
1418 }
1419}
1420
1421/// Finds the index of the last character in `haystack` that is also present in `needles`.
1422/// This can be used to find the last occurrence of any character from a specified set,

Callers 3

find_byte_fromFunction · 0.85
find_byte_not_fromFunction · 0.85
try_replace_all_bytesetFunction · 0.85

Calls 3

as_ptrMethod · 0.80
lenMethod · 0.80
sz_find_bytesetFunction · 0.50

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…