let string_rexists s ~f ~from:n = let rec loop n = if n = 0 then None else if f s.[n - 1] then Some n else loop (n - 1) in loop n