mirror of
https://github.com/c-cube/ocaml-containers.git
synced 2025-12-06 11:15:31 -05:00
add CCOpt.get_or with label, deprecates get
This commit is contained in:
parent
4c998bf57a
commit
cfad88e906
2 changed files with 13 additions and 2 deletions
|
|
@ -93,6 +93,10 @@ let get default x = match x with
|
|||
| None -> default
|
||||
| Some y -> y
|
||||
|
||||
let get_or ~default x = match x with
|
||||
| None -> default
|
||||
| Some y -> y
|
||||
|
||||
let get_exn = function
|
||||
| Some x -> x
|
||||
| None -> invalid_arg "CCOpt.get_exn"
|
||||
|
|
|
|||
|
|
@ -27,7 +27,7 @@ val compare : ('a -> 'a -> int) -> 'a t -> 'a t -> int
|
|||
val equal : ('a -> 'a -> bool) -> 'a t -> 'a t -> bool
|
||||
|
||||
val return : 'a -> 'a t
|
||||
(** Monadic return *)
|
||||
(** Monadic return, that is [return x = Some x] *)
|
||||
|
||||
val (>|=) : 'a t -> ('a -> 'b) -> 'b t
|
||||
(** Infix version of {!map} *)
|
||||
|
|
@ -62,7 +62,13 @@ val for_all : ('a -> bool) -> 'a t -> bool
|
|||
|
||||
val get : 'a -> 'a t -> 'a
|
||||
(** [get default x] unwraps [x], but if [x = None] it returns [default] instead.
|
||||
@since 0.4.1 *)
|
||||
@since 0.4.1
|
||||
@deprecated use {!get_or} @since NEXT_RELEASE *)
|
||||
|
||||
val get_or : default:'a -> 'a t -> 'a
|
||||
(** [get_or ~default o] extracts the value from [o], or
|
||||
returns [default] if [o = None].
|
||||
@since NEXT_RELEASE *)
|
||||
|
||||
val get_exn : 'a t -> 'a
|
||||
(** Open the option, possibly failing if it is [None]
|
||||
|
|
@ -103,6 +109,7 @@ val (<+>) : 'a t -> 'a t -> 'a t
|
|||
|
||||
val choice : 'a t list -> 'a t
|
||||
(** [choice] returns the first non-[None] element of the list, or [None] *)
|
||||
|
||||
(** {2 Infix Operators}
|
||||
@since 0.16 *)
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue