mirror of
https://github.com/c-cube/ocaml-containers.git
synced 2025-12-07 03:35:30 -05:00
more type safety in String.Find
This commit is contained in:
parent
5288713b76
commit
83b0744a1b
1 changed files with 3 additions and 3 deletions
|
|
@ -222,12 +222,12 @@ module Find = struct
|
||||||
then P_char sub.[0]
|
then P_char sub.[0]
|
||||||
else P_KMP (kmp_rcompile sub)
|
else P_KMP (kmp_rcompile sub)
|
||||||
|
|
||||||
let find ~pattern s start = match pattern with
|
let find ~(pattern:[`Direct] pattern) s start = match pattern with
|
||||||
| P_char c ->
|
| P_char c ->
|
||||||
(try String.index_from s start c with Not_found -> -1)
|
(try String.index_from s start c with Not_found -> -1)
|
||||||
| P_KMP pattern -> kmp_find ~pattern s start
|
| P_KMP pattern -> kmp_find ~pattern s start
|
||||||
|
|
||||||
let rfind ~pattern s start = match pattern with
|
let rfind ~(pattern:[`Reverse] pattern) s start = match pattern with
|
||||||
| P_char c ->
|
| P_char c ->
|
||||||
(try String.rindex_from s start c with Not_found -> -1)
|
(try String.rindex_from s start c with Not_found -> -1)
|
||||||
| P_KMP pattern -> kmp_rfind ~pattern s start
|
| P_KMP pattern -> kmp_rfind ~pattern s start
|
||||||
|
|
|
||||||
Loading…
Add table
Reference in a new issue