Lines Matching refs:needle
64 for &(needle, haystack, expected_fwd, _) in SEARCH_TESTS { in run_search_tests_fwd()
65 let (n, h) = (needle.as_bytes(), haystack.as_bytes()); in run_search_tests_fwd()
86 for &(needle, haystack, _, expected_rev) in SEARCH_TESTS { in run_search_tests_rev()
87 let (n, h) = (needle.as_bytes(), haystack.as_bytes()); in run_search_tests_rev()
118 needle: Vec<u8>,
123 &needle,
130 needle: Vec<u8>,
135 &needle,
186 needle: &[u8], in prop_matches_naive()
191 naive_rfind(needle, haystack) == search(needle, haystack) in prop_matches_naive()
193 naive_find(needle, haystack) == search(needle, haystack) in prop_matches_naive()
198 fn naive_find(needle: &[u8], haystack: &[u8]) -> Option<usize> { in naive_find()
199 if needle.is_empty() { in naive_find()
201 } else if haystack.len() < needle.len() { in naive_find()
204 for i in 0..(haystack.len() - needle.len() + 1) { in naive_find()
205 if needle == &haystack[i..i + needle.len()] { in naive_find()
213 fn naive_rfind(needle: &[u8], haystack: &[u8]) -> Option<usize> { in naive_rfind()
214 if needle.is_empty() { in naive_rfind()
216 } else if haystack.len() < needle.len() { in naive_rfind()
219 for i in (0..(haystack.len() - needle.len() + 1)).rev() { in naive_rfind()
220 if needle == &haystack[i..i + needle.len()] { in naive_rfind()