mirror of
https://github.com/c-cube/ocaml-containers.git
synced 2025-12-06 11:15:31 -05:00
Avoid catch-all handlers
This commit is contained in:
parent
8c33147d06
commit
2bf052ab7a
5 changed files with 5 additions and 9 deletions
|
|
@ -13,7 +13,7 @@ let pp_buf = Buffer.add_char
|
||||||
let pp = Format.pp_print_char
|
let pp = Format.pp_print_char
|
||||||
|
|
||||||
let of_int_exn = Char.chr
|
let of_int_exn = Char.chr
|
||||||
let of_int c = try Some (of_int_exn c) with _ -> None
|
let of_int c = try Some (of_int_exn c) with Invalid_argument _ -> None
|
||||||
let to_int = Char.code
|
let to_int = Char.code
|
||||||
|
|
||||||
(*$=
|
(*$=
|
||||||
|
|
|
||||||
|
|
@ -114,7 +114,7 @@ let of_string_exn (a:string) = Stdlib.float_of_string a
|
||||||
let of_string (a:string) = Stdlib.float_of_string a
|
let of_string (a:string) = Stdlib.float_of_string a
|
||||||
let of_string_opt (a:string) =
|
let of_string_opt (a:string) =
|
||||||
try Some (Stdlib.float_of_string a)
|
try Some (Stdlib.float_of_string a)
|
||||||
with _ -> None
|
with Failure _ -> None
|
||||||
|
|
||||||
|
|
||||||
let random n st = Random.State.float st n
|
let random n st = Random.State.float st n
|
||||||
|
|
|
||||||
|
|
@ -222,11 +222,7 @@ let with_in_out ?(mode=0o644) ?(flags=[Open_creat]) filename f =
|
||||||
let tee funs g () = match g() with
|
let tee funs g () = match g() with
|
||||||
| None -> None
|
| None -> None
|
||||||
| Some x as res ->
|
| Some x as res ->
|
||||||
List.iter
|
List.iter (fun f -> f x) funs;
|
||||||
(fun f ->
|
|
||||||
try f x
|
|
||||||
with _ -> ()
|
|
||||||
) funs;
|
|
||||||
res
|
res
|
||||||
|
|
||||||
(* TODO: lines/unlines: string gen -> string gen *)
|
(* TODO: lines/unlines: string gen -> string gen *)
|
||||||
|
|
|
||||||
|
|
@ -202,7 +202,7 @@ let to_string = string_of_int
|
||||||
|
|
||||||
let of_string s =
|
let of_string s =
|
||||||
try Some (int_of_string s)
|
try Some (int_of_string s)
|
||||||
with _ -> None
|
with Failure _ -> None
|
||||||
|
|
||||||
(*$=
|
(*$=
|
||||||
None (of_string "moo")
|
None (of_string "moo")
|
||||||
|
|
|
||||||
|
|
@ -589,7 +589,7 @@ let split_on_char c s: _ list =
|
||||||
let split ~by s = Split.list_cpy ~by s
|
let split ~by s = Split.list_cpy ~by s
|
||||||
|
|
||||||
let compare_versions a b =
|
let compare_versions a b =
|
||||||
let of_int s = try Some (int_of_string s) with _ -> None in
|
let of_int s = try Some (int_of_string s) with Failure _ -> None in
|
||||||
let rec cmp_rec a b = match a(), b() with
|
let rec cmp_rec a b = match a(), b() with
|
||||||
| None, None -> 0
|
| None, None -> 0
|
||||||
| Some _, None -> 1
|
| Some _, None -> 1
|
||||||
|
|
|
||||||
Loading…
Add table
Reference in a new issue