mirror of
https://github.com/c-cube/ocaml-containers.git
synced 2026-01-22 09:06:41 -05:00
add CCOpt.value to improve compat with Stdlib.Option
This commit is contained in:
parent
3804dbff86
commit
bd4e4d311d
2 changed files with 7 additions and 0 deletions
|
|
@ -106,6 +106,9 @@ let fold f acc o = match o with
|
|||
let get_or ~default x = match x with
|
||||
| None -> default
|
||||
| Some y -> y
|
||||
let value x ~default = match x with
|
||||
| None -> default
|
||||
| Some y -> y
|
||||
|
||||
let get_exn = function
|
||||
| Some x -> x
|
||||
|
|
|
|||
|
|
@ -72,6 +72,10 @@ val get_or : default:'a -> 'a t -> 'a
|
|||
returns [default] if [o = None].
|
||||
@since 0.18 *)
|
||||
|
||||
val value : 'a t -> default:'a -> 'a
|
||||
(** Similar to the stdlib's [Option.value] and to {!get_or}.
|
||||
@since NEXT_RELEASE *)
|
||||
|
||||
val get_exn : 'a t -> 'a
|
||||
(** Open the option, possibly failing if it is [None].
|
||||
@raise Invalid_argument if the option is [None]. *)
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue