mirror of
https://github.com/c-cube/ocaml-containers.git
synced 2025-12-06 03:05:28 -05:00
udpate doc and add test
This commit is contained in:
parent
3628feed9c
commit
c99f7818c3
2 changed files with 9 additions and 2 deletions
|
|
@ -114,6 +114,11 @@ let get_exn_or msg = function
|
||||||
| Some x -> x
|
| Some x -> x
|
||||||
| None -> invalid_arg msg
|
| 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
|
let get_lazy default_fn x = match x with
|
||||||
| None -> default_fn ()
|
| None -> default_fn ()
|
||||||
| Some y -> y
|
| Some y -> y
|
||||||
|
|
|
||||||
|
|
@ -95,8 +95,10 @@ val get_exn : 'a t -> 'a
|
||||||
*)
|
*)
|
||||||
|
|
||||||
val get_exn_or : string -> '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].
|
(** [get_exn_or msg o] returns [x] if [o] is [Some x]
|
||||||
@raise Invalid_argument if the option is [None]. *)
|
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
|
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.
|
(** [get_lazy default_fn o] unwraps [o], but if [o] is [None] it returns [default_fn ()] instead.
|
||||||
|
|
|
||||||
Loading…
Add table
Reference in a new issue