diff --git a/src/core/CCInt.ml b/src/core/CCInt.ml index 12a0d013..3d1cc631 100644 --- a/src/core/CCInt.ml +++ b/src/core/CCInt.ml @@ -70,3 +70,9 @@ let random_range i j st = i + random (j-i) st let pp buf = Printf.bprintf buf "%d" let print fmt = Format.pp_print_int fmt + +let to_string = string_of_int + +let of_string s = + try Some (int_of_string s) + with _ -> None diff --git a/src/core/CCInt.mli b/src/core/CCInt.mli index 9ad57969..c2b32fad 100644 --- a/src/core/CCInt.mli +++ b/src/core/CCInt.mli @@ -56,3 +56,10 @@ val random_range : int -> int -> t random_gen val pp : t printer val print : t formatter + +val to_string : t -> string +(** @since NEXT_RELEASE *) + +val of_string : string -> t option +(** @since NEXT_RELEASE *) +