From 1aa01548a612ef92a4eac8d6de996ec96a5701f5 Mon Sep 17 00:00:00 2001 From: Gustavo Leon <1261319+gusty@users.noreply.github.com> Date: Fri, 6 Oct 2023 20:14:56 +0200 Subject: [PATCH] + ValueOption.ofOption --- src/FSharpPlus/Extensions/ValueOption.fs | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/src/FSharpPlus/Extensions/ValueOption.fs b/src/FSharpPlus/Extensions/ValueOption.fs index 3a5ef1c93..4d269e1f8 100644 --- a/src/FSharpPlus/Extensions/ValueOption.fs +++ b/src/FSharpPlus/Extensions/ValueOption.fs @@ -71,7 +71,14 @@ module ValueOption = | true, x -> ValueSome x | false, _ -> ValueNone - let toOption x = - match x with + /// Converts a ValueOption to an Option. + let toOption (source: ValueOption<'T>) = + match source with | ValueSome x -> Some x | ValueNone -> None + + /// Converts an Option to a ValueOption. + let ofOption (source: option<'T>) = + match source with + | Some x -> ValueSome x + | None -> ValueNone