Returns unescaped constant prefix of a LIKE pattern (possibly empty) and the remaining pattern (possibly empty)
(pattern: &str)
| 1938 | |
| 1939 | /// Returns unescaped constant prefix of a LIKE pattern (possibly empty) and the remaining pattern (possibly empty) |
| 1940 | fn split_constant_prefix(pattern: &str) -> (String, &str) { |
| 1941 | let mut prefix = String::with_capacity(pattern.len()); |
| 1942 | let mut iter = pattern.char_indices(); |
| 1943 | while let Some((idx, c)) = iter.next() { |
| 1944 | match c { |
| 1945 | '%' | '_' => return (prefix, &pattern[idx..]), |
| 1946 | '\\' => match iter.next() { |
| 1947 | Some((_, escaped)) => prefix.push(escaped), |
| 1948 | None => prefix.push('\\'), |
| 1949 | }, |
| 1950 | _ => prefix.push(c), |
| 1951 | } |
| 1952 | } |
| 1953 | (prefix, "") |
| 1954 | } |
| 1955 | |
| 1956 | /// Increment a UTF8 string by one, returning `None` if it can't be incremented. |
| 1957 | /// This makes it so that the returned string will always compare greater than the input string |
no test coverage detected
searching dependent graphs…