(pat: &str, txt: &str)
| 3 | |
| 4 | #[deprecated(note = "brute force search used by benchmark, use KMP in production")] |
| 5 | pub fn search1(pat: &str, txt: &str) -> Option<usize> { |
| 6 | let M = pat.len(); |
| 7 | let N = txt.len(); |
| 8 | for i in 0..=(N - M) { |
| 9 | let mut j = 0; |
| 10 | while j < M { |
| 11 | let ic = common::util::byte_at(txt, i + j); |
| 12 | let jc = common::util::byte_at(pat, j); |
| 13 | if ic != jc { |
| 14 | break; |
| 15 | } |
| 16 | j += 1; |
| 17 | } |
| 18 | if j == M { |
| 19 | return Some(i); |
| 20 | } |
| 21 | } |
| 22 | |
| 23 | None |
| 24 | } |
| 25 | |
| 26 | #[deprecated(note = "brute force search used by benchmark, use KMP in production")] |
| 27 | pub fn search2(pat: &str, txt: &str) -> Option<usize> { |
no test coverage detected