diff --git a/src/core/CCOpt.ml b/src/core/CCOpt.ml index 10974bf5..7527077a 100644 --- a/src/core/CCOpt.ml +++ b/src/core/CCOpt.ml @@ -114,6 +114,11 @@ let get_exn_or msg = function | Some x -> x | None -> invalid_arg msg +(*$T + (try get_exn_or "ohno" (None:unit option); false with Invalid_argument s->s= "ohno") + 123 = get_exn_or "yes" (Some 123) +*) + let get_lazy default_fn x = match x with | None -> default_fn () | Some y -> y diff --git a/src/core/CCOpt.mli b/src/core/CCOpt.mli index 98992cf8..64f4b527 100644 --- a/src/core/CCOpt.mli +++ b/src/core/CCOpt.mli @@ -95,8 +95,10 @@ val get_exn : 'a t -> 'a *) 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]. *) +(** [get_exn_or 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]. + @since NEXT_RELEASE *) val get_lazy : (unit -> 'a) -> 'a t -> 'a (** [get_lazy default_fn o] unwraps [o], but if [o] is [None] it returns [default_fn ()] instead.