mirror of
https://github.com/c-cube/ocaml-containers.git
synced 2025-12-06 11:15:31 -05:00
Add CCOpt.get_exn_or and deprecate CCOpt.get_exn
This commit is contained in:
parent
0d9a3b82fa
commit
3628feed9c
2 changed files with 11 additions and 0 deletions
|
|
@ -110,6 +110,10 @@ let get_exn = function
|
|||
| Some x -> x
|
||||
| None -> invalid_arg "CCOpt.get_exn"
|
||||
|
||||
let get_exn_or msg = function
|
||||
| Some x -> x
|
||||
| None -> invalid_arg msg
|
||||
|
||||
let get_lazy default_fn x = match x with
|
||||
| None -> default_fn ()
|
||||
| Some y -> y
|
||||
|
|
|
|||
|
|
@ -88,7 +88,14 @@ val value : 'a t -> default:'a -> 'a
|
|||
@since 2.8 *)
|
||||
|
||||
val get_exn : 'a t -> 'a
|
||||
[@@ocaml.deprecated "use CCOpt.get_exn_or instead"]
|
||||
(** [get_exn o] returns [x] if [o] is [Some x] or fails if [o] is [None].
|
||||
@raise Invalid_argument if the option is [None].
|
||||
@deprecated use {!get_exn_or} instead
|
||||
*)
|
||||
|
||||
val get_exn_or : string -> 'a t -> 'a
|
||||
(** [get_exn msg o] returns [x] if [o] is [Some x] or fails with [Invalid_argument msg] if [o] is [None].
|
||||
@raise Invalid_argument if the option is [None]. *)
|
||||
|
||||
val get_lazy : (unit -> 'a) -> 'a t -> 'a
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue