File tree Expand file tree Collapse file tree
src/FSharpPlus/Extensions Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -70,3 +70,16 @@ module Option =
7070 match pair with
7171 | ( true , x) -> Some x
7272 | ( false , _) -> None
73+
74+ /// <summary >
75+ /// Extracts a value from either side of an Option.
76+ /// </summary >
77+ /// <param name =" fSome " >The function to apply if the option is Some.</param >
78+ /// <param name =" fNone " >The function to apply if the option is None.</param >
79+ /// <param name =" source " >The option to extract the value from.</param >
80+ #if ! NET45
81+ let inline either ( [<InlineIfLambda>] fSome : 'T -> 'U ) ( [<InlineIfLambda>] fNone : unit -> 'U ) ( source : option < 'T >) : 'U =
82+ #else
83+ let inline either ( fSome : 'T -> 'U ) ( fNone : unit -> 'U ) ( source : option < 'T >) : 'U =
84+ #endif
85+ match source with Some v -> fSome v | None -> fNone ()
Original file line number Diff line number Diff line change @@ -81,4 +81,17 @@ module ValueOption =
8181 let ofOption ( source : option < 'T >) =
8282 match source with
8383 | Some x -> ValueSome x
84- | None -> ValueNone
84+ | None -> ValueNone
85+
86+ /// <summary >
87+ /// Extracts a value from either side of a ValueOption.
88+ /// </summary >
89+ /// <param name =" fSome " >The function to apply if the option is ValueSome.</param >
90+ /// <param name =" fNone " >The function to apply if the option is ValueNone.</param >
91+ /// <param name =" source " >The option to extract the value from.</param >
92+ #if ! NET45
93+ let inline either ( [<InlineIfLambda>] fSome : 'T -> 'U ) ( [<InlineIfLambda>] fNone : unit -> 'U ) ( source : ValueOption < 'T >) : 'U =
94+ #else
95+ let inline either ( fSome : 'T -> 'U ) ( fNone : unit -> 'U ) ( source : ValueOption < 'T >) : 'U =
96+ #endif
97+ match source with ValueSome v -> fSome v | ValueNone -> fNone ()
You can’t perform that action at this time.
0 commit comments