Skip to content

OnixLabs.Core.OptionalExtensions

Matthew Layton edited this page Oct 22, 2026 · 1 revision

OptionalExtensions Class

Provides extension methods for Optional<T> instances — asynchronous combinators over Task<Optional<T>> and ValueTask<Optional<T>> that mirror the instance API of Optional<T>.

Namespace OnixLabs.Core
Assembly OnixLabs.Core.dll (NuGet)
Inheritance object → OptionalExtensions

Definition

[EditorBrowsable(EditorBrowsableState.Never)]
public static class OptionalExtensions

Note OptionalExtensions is decorated with [EditorBrowsable(EditorBrowsableState.Never)], so the class itself is hidden from IntelliSense completion lists. Its extension methods are fully callable; they appear on their receiver types at the call site as normal.

Remarks

All members are declared in C# 14 extension blocks over Task<Optional<T>> and ValueTask<Optional<T>> (both with T : notnull). Each member is shown below in its equivalent classic static-extension-method form, with the block's receiver as the leading this parameter named receiver; at the call site they are invoked as instance methods on the receiver.

Each member awaits the receiver and then applies the corresponding member of Optional<T>: GetValueOrDefaultAsync, GetValueOrThrowAsync, MatchAsync, SelectAsync, SelectManyAsync, and ToResultAsync. This lets an optional-producing asynchronous operation be consumed or composed without an intermediate await expression.

The return type follows the receiver: members on Task<Optional<T>> return Task or Task<…>, and members on ValueTask<Optional<T>> return ValueTask or ValueTask<…>. MatchAsync, SelectAsync, and SelectManyAsync accept synchronous delegates, Task-returning delegates, and ValueTask-returning delegates, each with and without a CancellationToken parameter. Every member accepts a trailing CancellationToken cancellationToken = default, the token to monitor for cancellation requests.

Overload resolution note Where both a Task-returning and a ValueTask-returning delegate overload exist, an async lambda (or a lambda whose body is only a throw expression) is convertible to both delegate types, so the call is ambiguous and fails with compiler error CS0121. Give the lambda an explicit return type to select an overload, for example async Task<Result> (_) => ... or async ValueTask (value) => .... Method groups and non-async lambdas that return an existing Task/ValueTask resolve without annotation.

Examples

Awaiting a Task<Optional<T>>

using OnixLabs.Core;

Task<Optional<User>> lookup = repository.FindUserAsync(id); // returns Task<Optional<User>>

string name = await lookup.MatchAsync(
    some: user => user.Name,
    none: () => "(unknown)");

Composing with async selectors

Optional<Profile> profile = await repository
    .FindUserAsync(id)
    .SelectManyAsync(async Task<Optional<Profile>> (user) => await profiles.FindAsync(user.Id));

Converting to a Result

Result<Optional<User>> result = await lookup.ToResultAsync();

Methods

The methods are grouped by receiver type. Select a method to view its full signature and parameters.

Extensions on Task<Optional<T>>

Each member awaits the Task (observing cancellationToken) and delegates to the corresponding member of Optional<T>. All members return Task or Task<…>.

Method Returns Description
GetValueOrDefaultAsync(CancellationToken) Task<T?> Asynchronously gets the underlying value of the current Optional<T> instance, if the underlying value is present; otherwise, returns the default T value.
GetValueOrDefaultAsync(T, CancellationToken) Task<T> Asynchronously gets the underlying value of the current Optional<T> instance, if the underlying value is present; otherwise, returns the specified default value.
GetValueOrThrowAsync(CancellationToken) Task<T> Asynchronously gets the underlying value of the current Optional<T> instance, if the underlying value is present; otherwise, throws an InvalidOperationException exception.
MatchAsync(Action<T>?, Action?, CancellationToken) Task Asynchronously executes the delegate that matches the value of the current Optional<T> instance. Delegates — some: synchronous; none: synchronous.
MatchAsync(Func<T, Task>?, Action?, CancellationToken) Task Asynchronously executes the delegate that matches the value of the current Optional<T> instance. Delegates — some: Task-returning; none: synchronous.
MatchAsync(Func<T, ValueTask>?, Action?, CancellationToken) Task Asynchronously executes the delegate that matches the value of the current Optional<T> instance. Delegates — some: ValueTask-returning; none: synchronous.
MatchAsync(Func<T, CancellationToken, Task>?, Action?, CancellationToken) Task Asynchronously executes the delegate that matches the value of the current Optional<T> instance. Delegates — some: Task-returning (cancellable); none: synchronous.
MatchAsync(Func<T, CancellationToken, ValueTask>?, Action?, CancellationToken) Task Asynchronously executes the delegate that matches the value of the current Optional<T> instance. Delegates — some: ValueTask-returning (cancellable); none: synchronous.
MatchAsync(Action<T>?, Func<Task>?, CancellationToken) Task Asynchronously executes the delegate that matches the value of the current Optional<T> instance. Delegates — some: synchronous; none: Task-returning.
MatchAsync(Action<T>?, Func<ValueTask>?, CancellationToken) Task Asynchronously executes the delegate that matches the value of the current Optional<T> instance. Delegates — some: synchronous; none: ValueTask-returning.
MatchAsync(Action<T>?, Func<CancellationToken, Task>?, CancellationToken) Task Asynchronously executes the delegate that matches the value of the current Optional<T> instance. Delegates — some: synchronous; none: Task-returning (cancellable).
MatchAsync(Action<T>?, Func<CancellationToken, ValueTask>?, CancellationToken) Task Asynchronously executes the delegate that matches the value of the current Optional<T> instance. Delegates — some: synchronous; none: ValueTask-returning (cancellable).
MatchAsync(Func<T, Task>?, Func<Task>?, CancellationToken) Task Asynchronously executes the delegate that matches the value of the current Optional<T> instance. Delegates — some: Task-returning; none: Task-returning.
MatchAsync(Func<T, ValueTask>?, Func<ValueTask>?, CancellationToken) Task Asynchronously executes the delegate that matches the value of the current Optional<T> instance. Delegates — some: ValueTask-returning; none: ValueTask-returning.
MatchAsync(Func<T, CancellationToken, Task>?, Func<CancellationToken, Task>?, CancellationToken) Task Asynchronously executes the delegate that matches the value of the current Optional<T> instance. Delegates — some: Task-returning (cancellable); none: Task-returning (cancellable).
MatchAsync(Func<T, CancellationToken, ValueTask>?, Func<CancellationToken, ValueTask>?, CancellationToken) Task Asynchronously executes the delegate that matches the value of the current Optional<T> instance. Delegates — some: ValueTask-returning (cancellable); none: ValueTask-returning (cancellable).
MatchAsync<TResult>(Func<T, TResult>, Func<TResult>, CancellationToken) Task<TResult> Asynchronously executes the delegate that matches the value of the current Optional<T> instance and returns its result. Delegates — some: synchronous; none: synchronous.
MatchAsync<TResult>(Func<T, Task<TResult>>, Func<TResult>, CancellationToken) Task<TResult> Asynchronously executes the delegate that matches the value of the current Optional<T> instance and returns its result. Delegates — some: Task-returning; none: synchronous.
MatchAsync<TResult>(Func<T, ValueTask<TResult>>, Func<TResult>, CancellationToken) Task<TResult> Asynchronously executes the delegate that matches the value of the current Optional<T> instance and returns its result. Delegates — some: ValueTask-returning; none: synchronous.
MatchAsync<TResult>(Func<T, CancellationToken, Task<TResult>>, Func<TResult>, CancellationToken) Task<TResult> Asynchronously executes the delegate that matches the value of the current Optional<T> instance and returns its result. Delegates — some: Task-returning (cancellable); none: synchronous.
MatchAsync<TResult>(Func<T, CancellationToken, ValueTask<TResult>>, Func<TResult>, CancellationToken) Task<TResult> Asynchronously executes the delegate that matches the value of the current Optional<T> instance and returns its result. Delegates — some: ValueTask-returning (cancellable); none: synchronous.
MatchAsync<TResult>(Func<T, TResult>, Func<Task<TResult>>, CancellationToken) Task<TResult> Asynchronously executes the delegate that matches the value of the current Optional<T> instance and returns its result. Delegates — some: synchronous; none: Task-returning.
MatchAsync<TResult>(Func<T, TResult>, Func<ValueTask<TResult>>, CancellationToken) Task<TResult> Asynchronously executes the delegate that matches the value of the current Optional<T> instance and returns its result. Delegates — some: synchronous; none: ValueTask-returning.
MatchAsync<TResult>(Func<T, TResult>, Func<CancellationToken, Task<TResult>>, CancellationToken) Task<TResult> Asynchronously executes the delegate that matches the value of the current Optional<T> instance and returns its result. Delegates — some: synchronous; none: Task-returning (cancellable).
MatchAsync<TResult>(Func<T, TResult>, Func<CancellationToken, ValueTask<TResult>>, CancellationToken) Task<TResult> Asynchronously executes the delegate that matches the value of the current Optional<T> instance and returns its result. Delegates — some: synchronous; none: ValueTask-returning (cancellable).
MatchAsync<TResult>(Func<T, Task<TResult>>, Func<Task<TResult>>, CancellationToken) Task<TResult> Asynchronously executes the delegate that matches the value of the current Optional<T> instance and returns its result. Delegates — some: Task-returning; none: Task-returning.
MatchAsync<TResult>(Func<T, ValueTask<TResult>>, Func<ValueTask<TResult>>, CancellationToken) Task<TResult> Asynchronously executes the delegate that matches the value of the current Optional<T> instance and returns its result. Delegates — some: ValueTask-returning; none: ValueTask-returning.
MatchAsync<TResult>(Func<T, CancellationToken, Task<TResult>>, Func<CancellationToken, Task<TResult>>, CancellationToken) Task<TResult> Asynchronously executes the delegate that matches the value of the current Optional<T> instance and returns its result. Delegates — some: Task-returning (cancellable); none: Task-returning (cancellable).
MatchAsync<TResult>(Func<T, CancellationToken, ValueTask<TResult>>, Func<CancellationToken, ValueTask<TResult>>, CancellationToken) Task<TResult> Asynchronously executes the delegate that matches the value of the current Optional<T> instance and returns its result. Delegates — some: ValueTask-returning (cancellable); none: ValueTask-returning (cancellable).
SelectAsync<TResult>(Func<T, TResult>, CancellationToken) Task<Optional<TResult>> Asynchronously applies the provided selector delegate to the value of the current Optional<T> instance. Delegates — selector: synchronous.
SelectAsync<TResult>(Func<T, Task<TResult>>, CancellationToken) Task<Optional<TResult>> Asynchronously applies the provided selector delegate to the value of the current Optional<T> instance. Delegates — selector: Task-returning.
SelectAsync<TResult>(Func<T, ValueTask<TResult>>, CancellationToken) Task<Optional<TResult>> Asynchronously applies the provided selector delegate to the value of the current Optional<T> instance. Delegates — selector: ValueTask-returning.
SelectAsync<TResult>(Func<T, CancellationToken, Task<TResult>>, CancellationToken) Task<Optional<TResult>> Asynchronously applies the provided selector delegate to the value of the current Optional<T> instance. Delegates — selector: Task-returning (cancellable).
SelectAsync<TResult>(Func<T, CancellationToken, ValueTask<TResult>>, CancellationToken) Task<Optional<TResult>> Asynchronously applies the provided selector delegate to the value of the current Optional<T> instance. Delegates — selector: ValueTask-returning (cancellable).
SelectManyAsync<TResult>(Func<T, Optional<TResult>>, CancellationToken) Task<Optional<TResult>> Asynchronously applies the provided selector delegate to the value of the current Optional<T> instance. Delegates — selector: synchronous.
SelectManyAsync<TResult>(Func<T, Task<Optional<TResult>>>, CancellationToken) Task<Optional<TResult>> Asynchronously applies the provided selector delegate to the value of the current Optional<T> instance. Delegates — selector: Task-returning.
SelectManyAsync<TResult>(Func<T, ValueTask<Optional<TResult>>>, CancellationToken) Task<Optional<TResult>> Asynchronously applies the provided selector delegate to the value of the current Optional<T> instance. Delegates — selector: ValueTask-returning.
SelectManyAsync<TResult>(Func<T, CancellationToken, Task<Optional<TResult>>>, CancellationToken) Task<Optional<TResult>> Asynchronously applies the provided selector delegate to the value of the current Optional<T> instance. Delegates — selector: Task-returning (cancellable).
SelectManyAsync<TResult>(Func<T, CancellationToken, ValueTask<Optional<TResult>>>, CancellationToken) Task<Optional<TResult>> Asynchronously applies the provided selector delegate to the value of the current Optional<T> instance. Delegates — selector: ValueTask-returning (cancellable).
ToResultAsync(CancellationToken) Task<Result<Optional<T>>> Asynchronously wraps the current Optional<T> instance into new, successful Result<T> instance.

Extensions on ValueTask<Optional<T>>

Each member awaits the ValueTask (observing cancellationToken) and delegates to the corresponding member of Optional<T>. All members return ValueTask or ValueTask<…>.

Method Returns Description
GetValueOrDefaultAsync(CancellationToken) ValueTask<T?> Asynchronously gets the underlying value of the current Optional<T> instance, if the underlying value is present; otherwise, returns the default T value.
GetValueOrDefaultAsync(T, CancellationToken) ValueTask<T> Asynchronously gets the underlying value of the current Optional<T> instance, if the underlying value is present; otherwise, returns the specified default value.
GetValueOrThrowAsync(CancellationToken) ValueTask<T> Asynchronously gets the underlying value of the current Optional<T> instance, if the underlying value is present; otherwise, throws an InvalidOperationException exception.
MatchAsync(Action<T>?, Action?, CancellationToken) ValueTask Asynchronously executes the delegate that matches the value of the current Optional<T> instance. Delegates — some: synchronous; none: synchronous.
MatchAsync(Func<T, Task>?, Action?, CancellationToken) ValueTask Asynchronously executes the delegate that matches the value of the current Optional<T> instance. Delegates — some: Task-returning; none: synchronous.
MatchAsync(Func<T, ValueTask>?, Action?, CancellationToken) ValueTask Asynchronously executes the delegate that matches the value of the current Optional<T> instance. Delegates — some: ValueTask-returning; none: synchronous.
MatchAsync(Func<T, CancellationToken, Task>?, Action?, CancellationToken) ValueTask Asynchronously executes the delegate that matches the value of the current Optional<T> instance. Delegates — some: Task-returning (cancellable); none: synchronous.
MatchAsync(Func<T, CancellationToken, ValueTask>?, Action?, CancellationToken) ValueTask Asynchronously executes the delegate that matches the value of the current Optional<T> instance. Delegates — some: ValueTask-returning (cancellable); none: synchronous.
MatchAsync(Action<T>?, Func<Task>?, CancellationToken) ValueTask Asynchronously executes the delegate that matches the value of the current Optional<T> instance. Delegates — some: synchronous; none: Task-returning.
MatchAsync(Action<T>?, Func<ValueTask>?, CancellationToken) ValueTask Asynchronously executes the delegate that matches the value of the current Optional<T> instance. Delegates — some: synchronous; none: ValueTask-returning.
MatchAsync(Action<T>?, Func<CancellationToken, Task>?, CancellationToken) ValueTask Asynchronously executes the delegate that matches the value of the current Optional<T> instance. Delegates — some: synchronous; none: Task-returning (cancellable).
MatchAsync(Action<T>?, Func<CancellationToken, ValueTask>?, CancellationToken) ValueTask Asynchronously executes the delegate that matches the value of the current Optional<T> instance. Delegates — some: synchronous; none: ValueTask-returning (cancellable).
MatchAsync(Func<T, Task>?, Func<Task>?, CancellationToken) ValueTask Asynchronously executes the delegate that matches the value of the current Optional<T> instance. Delegates — some: Task-returning; none: Task-returning.
MatchAsync(Func<T, ValueTask>?, Func<ValueTask>?, CancellationToken) ValueTask Asynchronously executes the delegate that matches the value of the current Optional<T> instance. Delegates — some: ValueTask-returning; none: ValueTask-returning.
MatchAsync(Func<T, CancellationToken, Task>?, Func<CancellationToken, Task>?, CancellationToken) ValueTask Asynchronously executes the delegate that matches the value of the current Optional<T> instance. Delegates — some: Task-returning (cancellable); none: Task-returning (cancellable).
MatchAsync(Func<T, CancellationToken, ValueTask>?, Func<CancellationToken, ValueTask>?, CancellationToken) ValueTask Asynchronously executes the delegate that matches the value of the current Optional<T> instance. Delegates — some: ValueTask-returning (cancellable); none: ValueTask-returning (cancellable).
MatchAsync<TResult>(Func<T, TResult>, Func<TResult>, CancellationToken) ValueTask<TResult> Asynchronously executes the delegate that matches the value of the current Optional<T> instance and returns its result. Delegates — some: synchronous; none: synchronous.
MatchAsync<TResult>(Func<T, Task<TResult>>, Func<TResult>, CancellationToken) ValueTask<TResult> Asynchronously executes the delegate that matches the value of the current Optional<T> instance and returns its result. Delegates — some: Task-returning; none: synchronous.
MatchAsync<TResult>(Func<T, ValueTask<TResult>>, Func<TResult>, CancellationToken) ValueTask<TResult> Asynchronously executes the delegate that matches the value of the current Optional<T> instance and returns its result. Delegates — some: ValueTask-returning; none: synchronous.
MatchAsync<TResult>(Func<T, CancellationToken, Task<TResult>>, Func<TResult>, CancellationToken) ValueTask<TResult> Asynchronously executes the delegate that matches the value of the current Optional<T> instance and returns its result. Delegates — some: Task-returning (cancellable); none: synchronous.
MatchAsync<TResult>(Func<T, CancellationToken, ValueTask<TResult>>, Func<TResult>, CancellationToken) ValueTask<TResult> Asynchronously executes the delegate that matches the value of the current Optional<T> instance and returns its result. Delegates — some: ValueTask-returning (cancellable); none: synchronous.
MatchAsync<TResult>(Func<T, TResult>, Func<Task<TResult>>, CancellationToken) ValueTask<TResult> Asynchronously executes the delegate that matches the value of the current Optional<T> instance and returns its result. Delegates — some: synchronous; none: Task-returning.
MatchAsync<TResult>(Func<T, TResult>, Func<ValueTask<TResult>>, CancellationToken) ValueTask<TResult> Asynchronously executes the delegate that matches the value of the current Optional<T> instance and returns its result. Delegates — some: synchronous; none: ValueTask-returning.
MatchAsync<TResult>(Func<T, TResult>, Func<CancellationToken, Task<TResult>>, CancellationToken) ValueTask<TResult> Asynchronously executes the delegate that matches the value of the current Optional<T> instance and returns its result. Delegates — some: synchronous; none: Task-returning (cancellable).
MatchAsync<TResult>(Func<T, TResult>, Func<CancellationToken, ValueTask<TResult>>, CancellationToken) ValueTask<TResult> Asynchronously executes the delegate that matches the value of the current Optional<T> instance and returns its result. Delegates — some: synchronous; none: ValueTask-returning (cancellable).
MatchAsync<TResult>(Func<T, Task<TResult>>, Func<Task<TResult>>, CancellationToken) ValueTask<TResult> Asynchronously executes the delegate that matches the value of the current Optional<T> instance and returns its result. Delegates — some: Task-returning; none: Task-returning.
MatchAsync<TResult>(Func<T, ValueTask<TResult>>, Func<ValueTask<TResult>>, CancellationToken) ValueTask<TResult> Asynchronously executes the delegate that matches the value of the current Optional<T> instance and returns its result. Delegates — some: ValueTask-returning; none: ValueTask-returning.
MatchAsync<TResult>(Func<T, CancellationToken, Task<TResult>>, Func<CancellationToken, Task<TResult>>, CancellationToken) ValueTask<TResult> Asynchronously executes the delegate that matches the value of the current Optional<T> instance and returns its result. Delegates — some: Task-returning (cancellable); none: Task-returning (cancellable).
MatchAsync<TResult>(Func<T, CancellationToken, ValueTask<TResult>>, Func<CancellationToken, ValueTask<TResult>>, CancellationToken) ValueTask<TResult> Asynchronously executes the delegate that matches the value of the current Optional<T> instance and returns its result. Delegates — some: ValueTask-returning (cancellable); none: ValueTask-returning (cancellable).
SelectAsync<TResult>(Func<T, TResult>, CancellationToken) ValueTask<Optional<TResult>> Asynchronously applies the provided selector delegate to the value of the current Optional<T> instance. Delegates — selector: synchronous.
SelectAsync<TResult>(Func<T, Task<TResult>>, CancellationToken) ValueTask<Optional<TResult>> Asynchronously applies the provided selector delegate to the value of the current Optional<T> instance. Delegates — selector: Task-returning.
SelectAsync<TResult>(Func<T, ValueTask<TResult>>, CancellationToken) ValueTask<Optional<TResult>> Asynchronously applies the provided selector delegate to the value of the current Optional<T> instance. Delegates — selector: ValueTask-returning.
SelectAsync<TResult>(Func<T, CancellationToken, Task<TResult>>, CancellationToken) ValueTask<Optional<TResult>> Asynchronously applies the provided selector delegate to the value of the current Optional<T> instance. Delegates — selector: Task-returning (cancellable).
SelectAsync<TResult>(Func<T, CancellationToken, ValueTask<TResult>>, CancellationToken) ValueTask<Optional<TResult>> Asynchronously applies the provided selector delegate to the value of the current Optional<T> instance. Delegates — selector: ValueTask-returning (cancellable).
SelectManyAsync<TResult>(Func<T, Optional<TResult>>, CancellationToken) ValueTask<Optional<TResult>> Asynchronously applies the provided selector delegate to the value of the current Optional<T> instance. Delegates — selector: synchronous.
SelectManyAsync<TResult>(Func<T, Task<Optional<TResult>>>, CancellationToken) ValueTask<Optional<TResult>> Asynchronously applies the provided selector delegate to the value of the current Optional<T> instance. Delegates — selector: Task-returning.
SelectManyAsync<TResult>(Func<T, ValueTask<Optional<TResult>>>, CancellationToken) ValueTask<Optional<TResult>> Asynchronously applies the provided selector delegate to the value of the current Optional<T> instance. Delegates — selector: ValueTask-returning.
SelectManyAsync<TResult>(Func<T, CancellationToken, Task<Optional<TResult>>>, CancellationToken) ValueTask<Optional<TResult>> Asynchronously applies the provided selector delegate to the value of the current Optional<T> instance. Delegates — selector: Task-returning (cancellable).
SelectManyAsync<TResult>(Func<T, CancellationToken, ValueTask<Optional<TResult>>>, CancellationToken) ValueTask<Optional<TResult>> Asynchronously applies the provided selector delegate to the value of the current Optional<T> instance. Delegates — selector: ValueTask-returning (cancellable).
ToResultAsync(CancellationToken) ValueTask<Result<Optional<T>>> Asynchronously wraps the current Optional<T> instance into new, successful Result<T> instance.

Method Details

Task<Optional<T>> receiver

GetValueOrDefaultAsync(CancellationToken)

public static async Task<T?> GetValueOrDefaultAsync<T>(this Task<Optional<T>> receiver, CancellationToken cancellationToken = default) where T : notnull

Asynchronously gets the underlying value of the current Optional<T> instance, if the underlying value is present; otherwise, returns the default T value.

Type Parameters

Type Parameter Description
T The type of the underlying optional value.

Parameters

Parameter Type Description
receiver Task<Optional<T>> The current Task<Optional<T>> instance.
cancellationToken CancellationToken The token to monitor for cancellation requests.

Returns — Task<T?>. The underlying value of the current Optional<T> instance, if the underlying value is present; otherwise, returns the default T value.


GetValueOrDefaultAsync(T, CancellationToken)

public static async Task<T> GetValueOrDefaultAsync<T>(this Task<Optional<T>> receiver, T defaultValue, CancellationToken cancellationToken = default) where T : notnull

Asynchronously gets the underlying value of the current Optional<T> instance, if the underlying value is present; otherwise, returns the specified default value.

Type Parameters

Type Parameter Description
T The type of the underlying optional value.

Parameters

Parameter Type Description
receiver Task<Optional<T>> The current Task<Optional<T>> instance.
defaultValue T The default value to return in the event that the underlying value is absent.
cancellationToken CancellationToken The token to monitor for cancellation requests.

Returns — Task<T>. The underlying value of the current Optional<T> instance, if the underlying value is present; otherwise, returns the specified default value.


GetValueOrThrowAsync(CancellationToken)

public static async Task<T> GetValueOrThrowAsync<T>(this Task<Optional<T>> receiver, CancellationToken cancellationToken = default) where T : notnull

Asynchronously gets the underlying value of the current Optional<T> instance, if the underlying value is present; otherwise, throws an InvalidOperationException exception.

Type Parameters

Type Parameter Description
T The type of the underlying optional value.

Parameters

Parameter Type Description
receiver Task<Optional<T>> The current Task<Optional<T>> instance.
cancellationToken CancellationToken The token to monitor for cancellation requests.

Returns — Task<T>. The underlying value of the current Optional<T> instance, if the underlying value is present; otherwise, throws an InvalidOperationException exception.


MatchAsync(Action<T>?, Action?, CancellationToken)

public static async Task MatchAsync<T>(this Task<Optional<T>> receiver, Action<T>? some = null, Action? none = null, CancellationToken cancellationToken = default) where T : notnull

Asynchronously executes the delegate that matches the value of the current Optional<T> instance.

Type Parameters

Type Parameter Description
T The type of the underlying optional value.

Parameters

Parameter Type Description
receiver Task<Optional<T>> The current Task<Optional<T>> instance.
some Action<T>? The delegate to execute when the underlying value of the current Optional<T> instance is present.
none Action? The delegate to execute when the underlying value of the current Optional<T> instance is absent.
cancellationToken CancellationToken The token to monitor for cancellation requests.

Returns — Task. A Task that represents the asynchronous operation.


MatchAsync(Func<T, Task>?, Action?, CancellationToken)

public static async Task MatchAsync<T>(this Task<Optional<T>> receiver, Func<T, Task>? some = null, Action? none = null, CancellationToken cancellationToken = default) where T : notnull

Asynchronously executes the delegate that matches the value of the current Optional<T> instance.

Type Parameters

Type Parameter Description
T The type of the underlying optional value.

Parameters

Parameter Type Description
receiver Task<Optional<T>> The current Task<Optional<T>> instance.
some Func<T, Task>? The delegate to execute when the underlying value of the current Optional<T> instance is present.
none Action? The delegate to execute when the underlying value of the current Optional<T> instance is absent.
cancellationToken CancellationToken The token to monitor for cancellation requests.

Returns — Task. A Task that represents the asynchronous operation.


MatchAsync(Func<T, ValueTask>?, Action?, CancellationToken)

public static async Task MatchAsync<T>(this Task<Optional<T>> receiver, Func<T, ValueTask>? some = null, Action? none = null, CancellationToken cancellationToken = default) where T : notnull

Asynchronously executes the delegate that matches the value of the current Optional<T> instance.

Type Parameters

Type Parameter Description
T The type of the underlying optional value.

Parameters

Parameter Type Description
receiver Task<Optional<T>> The current Task<Optional<T>> instance.
some Func<T, ValueTask>? The delegate to execute when the underlying value of the current Optional<T> instance is present.
none Action? The delegate to execute when the underlying value of the current Optional<T> instance is absent.
cancellationToken CancellationToken The token to monitor for cancellation requests.

Returns — Task. A Task that represents the asynchronous operation.


MatchAsync(Func<T, CancellationToken, Task>?, Action?, CancellationToken)

public static async Task MatchAsync<T>(this Task<Optional<T>> receiver, Func<T, CancellationToken, Task>? some = null, Action? none = null, CancellationToken cancellationToken = default) where T : notnull

Asynchronously executes the delegate that matches the value of the current Optional<T> instance.

Type Parameters

Type Parameter Description
T The type of the underlying optional value.

Parameters

Parameter Type Description
receiver Task<Optional<T>> The current Task<Optional<T>> instance.
some Func<T, CancellationToken, Task>? The delegate to execute when the underlying value of the current Optional<T> instance is present.
none Action? The delegate to execute when the underlying value of the current Optional<T> instance is absent.
cancellationToken CancellationToken The token to monitor for cancellation requests.

Returns — Task. A Task that represents the asynchronous operation.


MatchAsync(Func<T, CancellationToken, ValueTask>?, Action?, CancellationToken)

public static async Task MatchAsync<T>(this Task<Optional<T>> receiver, Func<T, CancellationToken, ValueTask>? some = null, Action? none = null, CancellationToken cancellationToken = default) where T : notnull

Asynchronously executes the delegate that matches the value of the current Optional<T> instance.

Type Parameters

Type Parameter Description
T The type of the underlying optional value.

Parameters

Parameter Type Description
receiver Task<Optional<T>> The current Task<Optional<T>> instance.
some Func<T, CancellationToken, ValueTask>? The delegate to execute when the underlying value of the current Optional<T> instance is present.
none Action? The delegate to execute when the underlying value of the current Optional<T> instance is absent.
cancellationToken CancellationToken The token to monitor for cancellation requests.

Returns — Task. A Task that represents the asynchronous operation.


MatchAsync(Action<T>?, Func<Task>?, CancellationToken)

public static async Task MatchAsync<T>(this Task<Optional<T>> receiver, Action<T>? some = null, Func<Task>? none = null, CancellationToken cancellationToken = default) where T : notnull

Asynchronously executes the delegate that matches the value of the current Optional<T> instance.

Type Parameters

Type Parameter Description
T The type of the underlying optional value.

Parameters

Parameter Type Description
receiver Task<Optional<T>> The current Task<Optional<T>> instance.
some Action<T>? The delegate to execute when the underlying value of the current Optional<T> instance is present.
none Func<Task>? The delegate to execute when the underlying value of the current Optional<T> instance is absent.
cancellationToken CancellationToken The token to monitor for cancellation requests.

Returns — Task. A Task that represents the asynchronous operation.


MatchAsync(Action<T>?, Func<ValueTask>?, CancellationToken)

public static async Task MatchAsync<T>(this Task<Optional<T>> receiver, Action<T>? some = null, Func<ValueTask>? none = null, CancellationToken cancellationToken = default) where T : notnull

Asynchronously executes the delegate that matches the value of the current Optional<T> instance.

Type Parameters

Type Parameter Description
T The type of the underlying optional value.

Parameters

Parameter Type Description
receiver Task<Optional<T>> The current Task<Optional<T>> instance.
some Action<T>? The delegate to execute when the underlying value of the current Optional<T> instance is present.
none Func<ValueTask>? The delegate to execute when the underlying value of the current Optional<T> instance is absent.
cancellationToken CancellationToken The token to monitor for cancellation requests.

Returns — Task. A Task that represents the asynchronous operation.


MatchAsync(Action<T>?, Func<CancellationToken, Task>?, CancellationToken)

public static async Task MatchAsync<T>(this Task<Optional<T>> receiver, Action<T>? some = null, Func<CancellationToken, Task>? none = null, CancellationToken cancellationToken = default) where T : notnull

Asynchronously executes the delegate that matches the value of the current Optional<T> instance.

Type Parameters

Type Parameter Description
T The type of the underlying optional value.

Parameters

Parameter Type Description
receiver Task<Optional<T>> The current Task<Optional<T>> instance.
some Action<T>? The delegate to execute when the underlying value of the current Optional<T> instance is present.
none Func<CancellationToken, Task>? The delegate to execute when the underlying value of the current Optional<T> instance is absent.
cancellationToken CancellationToken The token to monitor for cancellation requests.

Returns — Task. A Task that represents the asynchronous operation.


MatchAsync(Action<T>?, Func<CancellationToken, ValueTask>?, CancellationToken)

public static async Task MatchAsync<T>(this Task<Optional<T>> receiver, Action<T>? some = null, Func<CancellationToken, ValueTask>? none = null, CancellationToken cancellationToken = default) where T : notnull

Asynchronously executes the delegate that matches the value of the current Optional<T> instance.

Type Parameters

Type Parameter Description
T The type of the underlying optional value.

Parameters

Parameter Type Description
receiver Task<Optional<T>> The current Task<Optional<T>> instance.
some Action<T>? The delegate to execute when the underlying value of the current Optional<T> instance is present.
none Func<CancellationToken, ValueTask>? The delegate to execute when the underlying value of the current Optional<T> instance is absent.
cancellationToken CancellationToken The token to monitor for cancellation requests.

Returns — Task. A Task that represents the asynchronous operation.


MatchAsync(Func<T, Task>?, Func<Task>?, CancellationToken)

public static async Task MatchAsync<T>(this Task<Optional<T>> receiver, Func<T, Task>? some = null, Func<Task>? none = null, CancellationToken cancellationToken = default) where T : notnull

Asynchronously executes the delegate that matches the value of the current Optional<T> instance.

Type Parameters

Type Parameter Description
T The type of the underlying optional value.

Parameters

Parameter Type Description
receiver Task<Optional<T>> The current Task<Optional<T>> instance.
some Func<T, Task>? The delegate to execute when the underlying value of the current Optional<T> instance is present.
none Func<Task>? The delegate to execute when the underlying value of the current Optional<T> instance is absent.
cancellationToken CancellationToken The token to monitor for cancellation requests.

Returns — Task. A Task that represents the asynchronous operation.


MatchAsync(Func<T, ValueTask>?, Func<ValueTask>?, CancellationToken)

public static async Task MatchAsync<T>(this Task<Optional<T>> receiver, Func<T, ValueTask>? some = null, Func<ValueTask>? none = null, CancellationToken cancellationToken = default) where T : notnull

Asynchronously executes the delegate that matches the value of the current Optional<T> instance.

Type Parameters

Type Parameter Description
T The type of the underlying optional value.

Parameters

Parameter Type Description
receiver Task<Optional<T>> The current Task<Optional<T>> instance.
some Func<T, ValueTask>? The delegate to execute when the underlying value of the current Optional<T> instance is present.
none Func<ValueTask>? The delegate to execute when the underlying value of the current Optional<T> instance is absent.
cancellationToken CancellationToken The token to monitor for cancellation requests.

Returns — Task. A Task that represents the asynchronous operation.


MatchAsync(Func<T, CancellationToken, Task>?, Func<CancellationToken, Task>?, CancellationToken)

public static async Task MatchAsync<T>(this Task<Optional<T>> receiver, Func<T, CancellationToken, Task>? some = null, Func<CancellationToken, Task>? none = null, CancellationToken cancellationToken = default) where T : notnull

Asynchronously executes the delegate that matches the value of the current Optional<T> instance.

Type Parameters

Type Parameter Description
T The type of the underlying optional value.

Parameters

Parameter Type Description
receiver Task<Optional<T>> The current Task<Optional<T>> instance.
some Func<T, CancellationToken, Task>? The delegate to execute when the underlying value of the current Optional<T> instance is present.
none Func<CancellationToken, Task>? The delegate to execute when the underlying value of the current Optional<T> instance is absent.
cancellationToken CancellationToken The token to monitor for cancellation requests.

Returns — Task. A Task that represents the asynchronous operation.


MatchAsync(Func<T, CancellationToken, ValueTask>?, Func<CancellationToken, ValueTask>?, CancellationToken)

public static async Task MatchAsync<T>(this Task<Optional<T>> receiver, Func<T, CancellationToken, ValueTask>? some = null, Func<CancellationToken, ValueTask>? none = null, CancellationToken cancellationToken = default) where T : notnull

Asynchronously executes the delegate that matches the value of the current Optional<T> instance.

Type Parameters

Type Parameter Description
T The type of the underlying optional value.

Parameters

Parameter Type Description
receiver Task<Optional<T>> The current Task<Optional<T>> instance.
some Func<T, CancellationToken, ValueTask>? The delegate to execute when the underlying value of the current Optional<T> instance is present.
none Func<CancellationToken, ValueTask>? The delegate to execute when the underlying value of the current Optional<T> instance is absent.
cancellationToken CancellationToken The token to monitor for cancellation requests.

Returns — Task. A Task that represents the asynchronous operation.


MatchAsync<TResult>(Func<T, TResult>, Func<TResult>, CancellationToken)

public static async Task<TResult> MatchAsync<T, TResult>(this Task<Optional<T>> receiver, Func<T, TResult> some, Func<TResult> none, CancellationToken cancellationToken = default) where T : notnull

Asynchronously executes the delegate that matches the value of the current Optional<T> instance and returns its result.

Type Parameters

Type Parameter Description
T The type of the underlying optional value.
TResult The underlying type of the result produced by the matching delegate.

Parameters

Parameter Type Description
receiver Task<Optional<T>> The current Task<Optional<T>> instance.
some Func<T, TResult> The delegate to execute when the underlying value of the current Optional<T> instance is present.
none Func<TResult> The delegate to execute when the underlying value of the current Optional<T> instance is absent.
cancellationToken CancellationToken The token to monitor for cancellation requests.

Returns — Task<TResult>. The result of the some delegate if the underlying value of the current Optional<T> instance is present; otherwise, returns the result of the none delegate if the underlying value of the current Optional<T> instance is absent.


MatchAsync<TResult>(Func<T, Task<TResult>>, Func<TResult>, CancellationToken)

public static async Task<TResult> MatchAsync<T, TResult>(this Task<Optional<T>> receiver, Func<T, Task<TResult>> some, Func<TResult> none, CancellationToken cancellationToken = default) where T : notnull

Asynchronously executes the delegate that matches the value of the current Optional<T> instance and returns its result.

Type Parameters

Type Parameter Description
T The type of the underlying optional value.
TResult The underlying type of the result produced by the matching delegate.

Parameters

Parameter Type Description
receiver Task<Optional<T>> The current Task<Optional<T>> instance.
some Func<T, Task<TResult>> The delegate to execute when the underlying value of the current Optional<T> instance is present.
none Func<TResult> The delegate to execute when the underlying value of the current Optional<T> instance is absent.
cancellationToken CancellationToken The token to monitor for cancellation requests.

Returns — Task<TResult>. The result of the some delegate if the underlying value of the current Optional<T> instance is present; otherwise, returns the result of the none delegate if the underlying value of the current Optional<T> instance is absent.


MatchAsync<TResult>(Func<T, ValueTask<TResult>>, Func<TResult>, CancellationToken)

public static async Task<TResult> MatchAsync<T, TResult>(this Task<Optional<T>> receiver, Func<T, ValueTask<TResult>> some, Func<TResult> none, CancellationToken cancellationToken = default) where T : notnull

Asynchronously executes the delegate that matches the value of the current Optional<T> instance and returns its result.

Type Parameters

Type Parameter Description
T The type of the underlying optional value.
TResult The underlying type of the result produced by the matching delegate.

Parameters

Parameter Type Description
receiver Task<Optional<T>> The current Task<Optional<T>> instance.
some Func<T, ValueTask<TResult>> The delegate to execute when the underlying value of the current Optional<T> instance is present.
none Func<TResult> The delegate to execute when the underlying value of the current Optional<T> instance is absent.
cancellationToken CancellationToken The token to monitor for cancellation requests.

Returns — Task<TResult>. The result of the some delegate if the underlying value of the current Optional<T> instance is present; otherwise, returns the result of the none delegate if the underlying value of the current Optional<T> instance is absent.


MatchAsync<TResult>(Func<T, CancellationToken, Task<TResult>>, Func<TResult>, CancellationToken)

public static async Task<TResult> MatchAsync<T, TResult>(this Task<Optional<T>> receiver, Func<T, CancellationToken, Task<TResult>> some, Func<TResult> none, CancellationToken cancellationToken = default) where T : notnull

Asynchronously executes the delegate that matches the value of the current Optional<T> instance and returns its result.

Type Parameters

Type Parameter Description
T The type of the underlying optional value.
TResult The underlying type of the result produced by the matching delegate.

Parameters

Parameter Type Description
receiver Task<Optional<T>> The current Task<Optional<T>> instance.
some Func<T, CancellationToken, Task<TResult>> The delegate to execute when the underlying value of the current Optional<T> instance is present.
none Func<TResult> The delegate to execute when the underlying value of the current Optional<T> instance is absent.
cancellationToken CancellationToken The token to monitor for cancellation requests.

Returns — Task<TResult>. The result of the some delegate if the underlying value of the current Optional<T> instance is present; otherwise, returns the result of the none delegate if the underlying value of the current Optional<T> instance is absent.


MatchAsync<TResult>(Func<T, CancellationToken, ValueTask<TResult>>, Func<TResult>, CancellationToken)

public static async Task<TResult> MatchAsync<T, TResult>(this Task<Optional<T>> receiver, Func<T, CancellationToken, ValueTask<TResult>> some, Func<TResult> none, CancellationToken cancellationToken = default) where T : notnull

Asynchronously executes the delegate that matches the value of the current Optional<T> instance and returns its result.

Type Parameters

Type Parameter Description
T The type of the underlying optional value.
TResult The underlying type of the result produced by the matching delegate.

Parameters

Parameter Type Description
receiver Task<Optional<T>> The current Task<Optional<T>> instance.
some Func<T, CancellationToken, ValueTask<TResult>> The delegate to execute when the underlying value of the current Optional<T> instance is present.
none Func<TResult> The delegate to execute when the underlying value of the current Optional<T> instance is absent.
cancellationToken CancellationToken The token to monitor for cancellation requests.

Returns — Task<TResult>. The result of the some delegate if the underlying value of the current Optional<T> instance is present; otherwise, returns the result of the none delegate if the underlying value of the current Optional<T> instance is absent.


MatchAsync<TResult>(Func<T, TResult>, Func<Task<TResult>>, CancellationToken)

public static async Task<TResult> MatchAsync<T, TResult>(this Task<Optional<T>> receiver, Func<T, TResult> some, Func<Task<TResult>> none, CancellationToken cancellationToken = default) where T : notnull

Asynchronously executes the delegate that matches the value of the current Optional<T> instance and returns its result.

Type Parameters

Type Parameter Description
T The type of the underlying optional value.
TResult The underlying type of the result produced by the matching delegate.

Parameters

Parameter Type Description
receiver Task<Optional<T>> The current Task<Optional<T>> instance.
some Func<T, TResult> The delegate to execute when the underlying value of the current Optional<T> instance is present.
none Func<Task<TResult>> The delegate to execute when the underlying value of the current Optional<T> instance is absent.
cancellationToken CancellationToken The token to monitor for cancellation requests.

Returns — Task<TResult>. The result of the some delegate if the underlying value of the current Optional<T> instance is present; otherwise, returns the result of the none delegate if the underlying value of the current Optional<T> instance is absent.


MatchAsync<TResult>(Func<T, TResult>, Func<ValueTask<TResult>>, CancellationToken)

public static async Task<TResult> MatchAsync<T, TResult>(this Task<Optional<T>> receiver, Func<T, TResult> some, Func<ValueTask<TResult>> none, CancellationToken cancellationToken = default) where T : notnull

Asynchronously executes the delegate that matches the value of the current Optional<T> instance and returns its result.

Type Parameters

Type Parameter Description
T The type of the underlying optional value.
TResult The underlying type of the result produced by the matching delegate.

Parameters

Parameter Type Description
receiver Task<Optional<T>> The current Task<Optional<T>> instance.
some Func<T, TResult> The delegate to execute when the underlying value of the current Optional<T> instance is present.
none Func<ValueTask<TResult>> The delegate to execute when the underlying value of the current Optional<T> instance is absent.
cancellationToken CancellationToken The token to monitor for cancellation requests.

Returns — Task<TResult>. The result of the some delegate if the underlying value of the current Optional<T> instance is present; otherwise, returns the result of the none delegate if the underlying value of the current Optional<T> instance is absent.


MatchAsync<TResult>(Func<T, TResult>, Func<CancellationToken, Task<TResult>>, CancellationToken)

public static async Task<TResult> MatchAsync<T, TResult>(this Task<Optional<T>> receiver, Func<T, TResult> some, Func<CancellationToken, Task<TResult>> none, CancellationToken cancellationToken = default) where T : notnull

Asynchronously executes the delegate that matches the value of the current Optional<T> instance and returns its result.

Type Parameters

Type Parameter Description
T The type of the underlying optional value.
TResult The underlying type of the result produced by the matching delegate.

Parameters

Parameter Type Description
receiver Task<Optional<T>> The current Task<Optional<T>> instance.
some Func<T, TResult> The delegate to execute when the underlying value of the current Optional<T> instance is present.
none Func<CancellationToken, Task<TResult>> The delegate to execute when the underlying value of the current Optional<T> instance is absent.
cancellationToken CancellationToken The token to monitor for cancellation requests.

Returns — Task<TResult>. The result of the some delegate if the underlying value of the current Optional<T> instance is present; otherwise, returns the result of the none delegate if the underlying value of the current Optional<T> instance is absent.


MatchAsync<TResult>(Func<T, TResult>, Func<CancellationToken, ValueTask<TResult>>, CancellationToken)

public static async Task<TResult> MatchAsync<T, TResult>(this Task<Optional<T>> receiver, Func<T, TResult> some, Func<CancellationToken, ValueTask<TResult>> none, CancellationToken cancellationToken = default) where T : notnull

Asynchronously executes the delegate that matches the value of the current Optional<T> instance and returns its result.

Type Parameters

Type Parameter Description
T The type of the underlying optional value.
TResult The underlying type of the result produced by the matching delegate.

Parameters

Parameter Type Description
receiver Task<Optional<T>> The current Task<Optional<T>> instance.
some Func<T, TResult> The delegate to execute when the underlying value of the current Optional<T> instance is present.
none Func<CancellationToken, ValueTask<TResult>> The delegate to execute when the underlying value of the current Optional<T> instance is absent.
cancellationToken CancellationToken The token to monitor for cancellation requests.

Returns — Task<TResult>. The result of the some delegate if the underlying value of the current Optional<T> instance is present; otherwise, returns the result of the none delegate if the underlying value of the current Optional<T> instance is absent.


MatchAsync<TResult>(Func<T, Task<TResult>>, Func<Task<TResult>>, CancellationToken)

public static async Task<TResult> MatchAsync<T, TResult>(this Task<Optional<T>> receiver, Func<T, Task<TResult>> some, Func<Task<TResult>> none, CancellationToken cancellationToken = default) where T : notnull

Asynchronously executes the delegate that matches the value of the current Optional<T> instance and returns its result.

Type Parameters

Type Parameter Description
T The type of the underlying optional value.
TResult The underlying type of the result produced by the matching delegate.

Parameters

Parameter Type Description
receiver Task<Optional<T>> The current Task<Optional<T>> instance.
some Func<T, Task<TResult>> The delegate to execute when the underlying value of the current Optional<T> instance is present.
none Func<Task<TResult>> The delegate to execute when the underlying value of the current Optional<T> instance is absent.
cancellationToken CancellationToken The token to monitor for cancellation requests.

Returns — Task<TResult>. The result of the some delegate if the underlying value of the current Optional<T> instance is present; otherwise, returns the result of the none delegate if the underlying value of the current Optional<T> instance is absent.


MatchAsync<TResult>(Func<T, ValueTask<TResult>>, Func<ValueTask<TResult>>, CancellationToken)

public static async Task<TResult> MatchAsync<T, TResult>(this Task<Optional<T>> receiver, Func<T, ValueTask<TResult>> some, Func<ValueTask<TResult>> none, CancellationToken cancellationToken = default) where T : notnull

Asynchronously executes the delegate that matches the value of the current Optional<T> instance and returns its result.

Type Parameters

Type Parameter Description
T The type of the underlying optional value.
TResult The underlying type of the result produced by the matching delegate.

Parameters

Parameter Type Description
receiver Task<Optional<T>> The current Task<Optional<T>> instance.
some Func<T, ValueTask<TResult>> The delegate to execute when the underlying value of the current Optional<T> instance is present.
none Func<ValueTask<TResult>> The delegate to execute when the underlying value of the current Optional<T> instance is absent.
cancellationToken CancellationToken The token to monitor for cancellation requests.

Returns — Task<TResult>. The result of the some delegate if the underlying value of the current Optional<T> instance is present; otherwise, returns the result of the none delegate if the underlying value of the current Optional<T> instance is absent.


MatchAsync<TResult>(Func<T, CancellationToken, Task<TResult>>, Func<CancellationToken, Task<TResult>>, CancellationToken)

public static async Task<TResult> MatchAsync<T, TResult>(this Task<Optional<T>> receiver, Func<T, CancellationToken, Task<TResult>> some, Func<CancellationToken, Task<TResult>> none, CancellationToken cancellationToken = default) where T : notnull

Asynchronously executes the delegate that matches the value of the current Optional<T> instance and returns its result.

Type Parameters

Type Parameter Description
T The type of the underlying optional value.
TResult The underlying type of the result produced by the matching delegate.

Parameters

Parameter Type Description
receiver Task<Optional<T>> The current Task<Optional<T>> instance.
some Func<T, CancellationToken, Task<TResult>> The delegate to execute when the underlying value of the current Optional<T> instance is present.
none Func<CancellationToken, Task<TResult>> The delegate to execute when the underlying value of the current Optional<T> instance is absent.
cancellationToken CancellationToken The token to monitor for cancellation requests.

Returns — Task<TResult>. The result of the some delegate if the underlying value of the current Optional<T> instance is present; otherwise, returns the result of the none delegate if the underlying value of the current Optional<T> instance is absent.


MatchAsync<TResult>(Func<T, CancellationToken, ValueTask<TResult>>, Func<CancellationToken, ValueTask<TResult>>, CancellationToken)

public static async Task<TResult> MatchAsync<T, TResult>(this Task<Optional<T>> receiver, Func<T, CancellationToken, ValueTask<TResult>> some, Func<CancellationToken, ValueTask<TResult>> none, CancellationToken cancellationToken = default) where T : notnull

Asynchronously executes the delegate that matches the value of the current Optional<T> instance and returns its result.

Type Parameters

Type Parameter Description
T The type of the underlying optional value.
TResult The underlying type of the result produced by the matching delegate.

Parameters

Parameter Type Description
receiver Task<Optional<T>> The current Task<Optional<T>> instance.
some Func<T, CancellationToken, ValueTask<TResult>> The delegate to execute when the underlying value of the current Optional<T> instance is present.
none Func<CancellationToken, ValueTask<TResult>> The delegate to execute when the underlying value of the current Optional<T> instance is absent.
cancellationToken CancellationToken The token to monitor for cancellation requests.

Returns — Task<TResult>. The result of the some delegate if the underlying value of the current Optional<T> instance is present; otherwise, returns the result of the none delegate if the underlying value of the current Optional<T> instance is absent.


SelectAsync<TResult>(Func<T, TResult>, CancellationToken)

public static async Task<Optional<TResult>> SelectAsync<T, TResult>(this Task<Optional<T>> receiver, Func<T, TResult> selector, CancellationToken cancellationToken = default) where T : notnull where TResult : notnull

Asynchronously applies the provided selector delegate to the value of the current Optional<T> instance.

Type Parameters

Type Parameter Description
T The type of the underlying optional value.
TResult The underlying type of the result produced by the selector delegate.

Parameters

Parameter Type Description
receiver Task<Optional<T>> The current Task<Optional<T>> instance.
selector Func<T, TResult> The delegate to apply to the value of the current Optional<T> instance.
cancellationToken CancellationToken The token to monitor for cancellation requests.

Returns — Task<Optional<TResult>>. A new Optional<TResult> instance containing the result of the delegate if the current Optional<T> instance has an underlying value; otherwise, Optional<TResult>.None.


SelectAsync<TResult>(Func<T, Task<TResult>>, CancellationToken)

public static async Task<Optional<TResult>> SelectAsync<T, TResult>(this Task<Optional<T>> receiver, Func<T, Task<TResult>> selector, CancellationToken cancellationToken = default) where T : notnull where TResult : notnull

Asynchronously applies the provided selector delegate to the value of the current Optional<T> instance.

Type Parameters

Type Parameter Description
T The type of the underlying optional value.
TResult The underlying type of the result produced by the selector delegate.

Parameters

Parameter Type Description
receiver Task<Optional<T>> The current Task<Optional<T>> instance.
selector Func<T, Task<TResult>> The delegate to apply to the value of the current Optional<T> instance.
cancellationToken CancellationToken The token to monitor for cancellation requests.

Returns — Task<Optional<TResult>>. A new Optional<TResult> instance containing the result of the delegate if the current Optional<T> instance has an underlying value; otherwise, Optional<TResult>.None.


SelectAsync<TResult>(Func<T, ValueTask<TResult>>, CancellationToken)

public static async Task<Optional<TResult>> SelectAsync<T, TResult>(this Task<Optional<T>> receiver, Func<T, ValueTask<TResult>> selector, CancellationToken cancellationToken = default) where T : notnull where TResult : notnull

Asynchronously applies the provided selector delegate to the value of the current Optional<T> instance.

Type Parameters

Type Parameter Description
T The type of the underlying optional value.
TResult The underlying type of the result produced by the selector delegate.

Parameters

Parameter Type Description
receiver Task<Optional<T>> The current Task<Optional<T>> instance.
selector Func<T, ValueTask<TResult>> The delegate to apply to the value of the current Optional<T> instance.
cancellationToken CancellationToken The token to monitor for cancellation requests.

Returns — Task<Optional<TResult>>. A new Optional<TResult> instance containing the result of the delegate if the current Optional<T> instance has an underlying value; otherwise, Optional<TResult>.None.


SelectAsync<TResult>(Func<T, CancellationToken, Task<TResult>>, CancellationToken)

public static async Task<Optional<TResult>> SelectAsync<T, TResult>(this Task<Optional<T>> receiver, Func<T, CancellationToken, Task<TResult>> selector, CancellationToken cancellationToken = default) where T : notnull where TResult : notnull

Asynchronously applies the provided selector delegate to the value of the current Optional<T> instance.

Type Parameters

Type Parameter Description
T The type of the underlying optional value.
TResult The underlying type of the result produced by the selector delegate.

Parameters

Parameter Type Description
receiver Task<Optional<T>> The current Task<Optional<T>> instance.
selector Func<T, CancellationToken, Task<TResult>> The delegate to apply to the value of the current Optional<T> instance.
cancellationToken CancellationToken The token to monitor for cancellation requests.

Returns — Task<Optional<TResult>>. A new Optional<TResult> instance containing the result of the delegate if the current Optional<T> instance has an underlying value; otherwise, Optional<TResult>.None.


SelectAsync<TResult>(Func<T, CancellationToken, ValueTask<TResult>>, CancellationToken)

public static async Task<Optional<TResult>> SelectAsync<T, TResult>(this Task<Optional<T>> receiver, Func<T, CancellationToken, ValueTask<TResult>> selector, CancellationToken cancellationToken = default) where T : notnull where TResult : notnull

Asynchronously applies the provided selector delegate to the value of the current Optional<T> instance.

Type Parameters

Type Parameter Description
T The type of the underlying optional value.
TResult The underlying type of the result produced by the selector delegate.

Parameters

Parameter Type Description
receiver Task<Optional<T>> The current Task<Optional<T>> instance.
selector Func<T, CancellationToken, ValueTask<TResult>> The delegate to apply to the value of the current Optional<T> instance.
cancellationToken CancellationToken The token to monitor for cancellation requests.

Returns — Task<Optional<TResult>>. A new Optional<TResult> instance containing the result of the delegate if the current Optional<T> instance has an underlying value; otherwise, Optional<TResult>.None.


SelectManyAsync<TResult>(Func<T, Optional<TResult>>, CancellationToken)

public static async Task<Optional<TResult>> SelectManyAsync<T, TResult>(this Task<Optional<T>> receiver, Func<T, Optional<TResult>> selector, CancellationToken cancellationToken = default) where T : notnull where TResult : notnull

Asynchronously applies the provided selector delegate to the value of the current Optional<T> instance.

Type Parameters

Type Parameter Description
T The type of the underlying optional value.
TResult The underlying type of the result produced by the selector delegate.

Parameters

Parameter Type Description
receiver Task<Optional<T>> The current Task<Optional<T>> instance.
selector Func<T, Optional<TResult>> The delegate to apply to the value of the current Optional<T> instance.
cancellationToken CancellationToken The token to monitor for cancellation requests.

Returns — Task<Optional<TResult>>. A new Optional<TResult> instance containing the result of the delegate if the current Optional<T> instance has an underlying value; otherwise, Optional<TResult>.None.


SelectManyAsync<TResult>(Func<T, Task<Optional<TResult>>>, CancellationToken)

public static async Task<Optional<TResult>> SelectManyAsync<T, TResult>(this Task<Optional<T>> receiver, Func<T, Task<Optional<TResult>>> selector, CancellationToken cancellationToken = default) where T : notnull where TResult : notnull

Asynchronously applies the provided selector delegate to the value of the current Optional<T> instance.

Type Parameters

Type Parameter Description
T The type of the underlying optional value.
TResult The underlying type of the result produced by the selector delegate.

Parameters

Parameter Type Description
receiver Task<Optional<T>> The current Task<Optional<T>> instance.
selector Func<T, Task<Optional<TResult>>> The delegate to apply to the value of the current Optional<T> instance.
cancellationToken CancellationToken The token to monitor for cancellation requests.

Returns — Task<Optional<TResult>>. A new Optional<TResult> instance containing the result of the delegate if the current Optional<T> instance has an underlying value; otherwise, Optional<TResult>.None.


SelectManyAsync<TResult>(Func<T, ValueTask<Optional<TResult>>>, CancellationToken)

public static async Task<Optional<TResult>> SelectManyAsync<T, TResult>(this Task<Optional<T>> receiver, Func<T, ValueTask<Optional<TResult>>> selector, CancellationToken cancellationToken = default) where T : notnull where TResult : notnull

Asynchronously applies the provided selector delegate to the value of the current Optional<T> instance.

Type Parameters

Type Parameter Description
T The type of the underlying optional value.
TResult The underlying type of the result produced by the selector delegate.

Parameters

Parameter Type Description
receiver Task<Optional<T>> The current Task<Optional<T>> instance.
selector Func<T, ValueTask<Optional<TResult>>> The delegate to apply to the value of the current Optional<T> instance.
cancellationToken CancellationToken The token to monitor for cancellation requests.

Returns — Task<Optional<TResult>>. A new Optional<TResult> instance containing the result of the delegate if the current Optional<T> instance has an underlying value; otherwise, Optional<TResult>.None.


SelectManyAsync<TResult>(Func<T, CancellationToken, Task<Optional<TResult>>>, CancellationToken)

public static async Task<Optional<TResult>> SelectManyAsync<T, TResult>(this Task<Optional<T>> receiver, Func<T, CancellationToken, Task<Optional<TResult>>> selector, CancellationToken cancellationToken = default) where T : notnull where TResult : notnull

Asynchronously applies the provided selector delegate to the value of the current Optional<T> instance.

Type Parameters

Type Parameter Description
T The type of the underlying optional value.
TResult The underlying type of the result produced by the selector delegate.

Parameters

Parameter Type Description
receiver Task<Optional<T>> The current Task<Optional<T>> instance.
selector Func<T, CancellationToken, Task<Optional<TResult>>> The delegate to apply to the value of the current Optional<T> instance.
cancellationToken CancellationToken The token to monitor for cancellation requests.

Returns — Task<Optional<TResult>>. A new Optional<TResult> instance containing the result of the delegate if the current Optional<T> instance has an underlying value; otherwise, Optional<TResult>.None.


SelectManyAsync<TResult>(Func<T, CancellationToken, ValueTask<Optional<TResult>>>, CancellationToken)

public static async Task<Optional<TResult>> SelectManyAsync<T, TResult>(this Task<Optional<T>> receiver, Func<T, CancellationToken, ValueTask<Optional<TResult>>> selector, CancellationToken cancellationToken = default) where T : notnull where TResult : notnull

Asynchronously applies the provided selector delegate to the value of the current Optional<T> instance.

Type Parameters

Type Parameter Description
T The type of the underlying optional value.
TResult The underlying type of the result produced by the selector delegate.

Parameters

Parameter Type Description
receiver Task<Optional<T>> The current Task<Optional<T>> instance.
selector Func<T, CancellationToken, ValueTask<Optional<TResult>>> The delegate to apply to the value of the current Optional<T> instance.
cancellationToken CancellationToken The token to monitor for cancellation requests.

Returns — Task<Optional<TResult>>. A new Optional<TResult> instance containing the result of the delegate if the current Optional<T> instance has an underlying value; otherwise, Optional<TResult>.None.


ToResultAsync(CancellationToken)

public static async Task<Result<Optional<T>>> ToResultAsync<T>(this Task<Optional<T>> receiver, CancellationToken cancellationToken = default) where T : notnull

Asynchronously wraps the current Optional<T> instance into new, successful Result<T> instance.

Type Parameters

Type Parameter Description
T The type of the underlying optional value.

Parameters

Parameter Type Description
receiver Task<Optional<T>> The current Task<Optional<T>> instance.
cancellationToken CancellationToken The token to monitor for cancellation requests.

Returns — Task<Result<Optional<T>>>. A new, successful Result<T> instance containing the current Optional<T> instance.


ValueTask<Optional<T>> receiver

GetValueOrDefaultAsync(CancellationToken)

public static async ValueTask<T?> GetValueOrDefaultAsync<T>(this ValueTask<Optional<T>> receiver, CancellationToken cancellationToken = default) where T : notnull

Asynchronously gets the underlying value of the current Optional<T> instance, if the underlying value is present; otherwise, returns the default T value.

Type Parameters

Type Parameter Description
T The type of the underlying optional value.

Parameters

Parameter Type Description
receiver ValueTask<Optional<T>> The current ValueTask<Optional<T>> instance.
cancellationToken CancellationToken The token to monitor for cancellation requests.

Returns — ValueTask<T?>. The underlying value of the current Optional<T> instance, if the underlying value is present; otherwise, returns the default T value.


GetValueOrDefaultAsync(T, CancellationToken)

public static async ValueTask<T> GetValueOrDefaultAsync<T>(this ValueTask<Optional<T>> receiver, T defaultValue, CancellationToken cancellationToken = default) where T : notnull

Asynchronously gets the underlying value of the current Optional<T> instance, if the underlying value is present; otherwise, returns the specified default value.

Type Parameters

Type Parameter Description
T The type of the underlying optional value.

Parameters

Parameter Type Description
receiver ValueTask<Optional<T>> The current ValueTask<Optional<T>> instance.
defaultValue T The default value to return in the event that the underlying value is absent.
cancellationToken CancellationToken The token to monitor for cancellation requests.

Returns — ValueTask<T>. The underlying value of the current Optional<T> instance, if the underlying value is present; otherwise, returns the specified default value.


GetValueOrThrowAsync(CancellationToken)

public static async ValueTask<T> GetValueOrThrowAsync<T>(this ValueTask<Optional<T>> receiver, CancellationToken cancellationToken = default) where T : notnull

Asynchronously gets the underlying value of the current Optional<T> instance, if the underlying value is present; otherwise, throws an InvalidOperationException exception.

Type Parameters

Type Parameter Description
T The type of the underlying optional value.

Parameters

Parameter Type Description
receiver ValueTask<Optional<T>> The current ValueTask<Optional<T>> instance.
cancellationToken CancellationToken The token to monitor for cancellation requests.

Returns — ValueTask<T>. The underlying value of the current Optional<T> instance, if the underlying value is present; otherwise, throws an InvalidOperationException exception.


MatchAsync(Action<T>?, Action?, CancellationToken)

public static async ValueTask MatchAsync<T>(this ValueTask<Optional<T>> receiver, Action<T>? some = null, Action? none = null, CancellationToken cancellationToken = default) where T : notnull

Asynchronously executes the delegate that matches the value of the current Optional<T> instance.

Type Parameters

Type Parameter Description
T The type of the underlying optional value.

Parameters

Parameter Type Description
receiver ValueTask<Optional<T>> The current ValueTask<Optional<T>> instance.
some Action<T>? The delegate to execute when the underlying value of the current Optional<T> instance is present.
none Action? The delegate to execute when the underlying value of the current Optional<T> instance is absent.
cancellationToken CancellationToken The token to monitor for cancellation requests.

Returns — ValueTask. A ValueTask that represents the asynchronous operation.


MatchAsync(Func<T, Task>?, Action?, CancellationToken)

public static async ValueTask MatchAsync<T>(this ValueTask<Optional<T>> receiver, Func<T, Task>? some = null, Action? none = null, CancellationToken cancellationToken = default) where T : notnull

Asynchronously executes the delegate that matches the value of the current Optional<T> instance.

Type Parameters

Type Parameter Description
T The type of the underlying optional value.

Parameters

Parameter Type Description
receiver ValueTask<Optional<T>> The current ValueTask<Optional<T>> instance.
some Func<T, Task>? The delegate to execute when the underlying value of the current Optional<T> instance is present.
none Action? The delegate to execute when the underlying value of the current Optional<T> instance is absent.
cancellationToken CancellationToken The token to monitor for cancellation requests.

Returns — ValueTask. A ValueTask that represents the asynchronous operation.


MatchAsync(Func<T, ValueTask>?, Action?, CancellationToken)

public static async ValueTask MatchAsync<T>(this ValueTask<Optional<T>> receiver, Func<T, ValueTask>? some = null, Action? none = null, CancellationToken cancellationToken = default) where T : notnull

Asynchronously executes the delegate that matches the value of the current Optional<T> instance.

Type Parameters

Type Parameter Description
T The type of the underlying optional value.

Parameters

Parameter Type Description
receiver ValueTask<Optional<T>> The current ValueTask<Optional<T>> instance.
some Func<T, ValueTask>? The delegate to execute when the underlying value of the current Optional<T> instance is present.
none Action? The delegate to execute when the underlying value of the current Optional<T> instance is absent.
cancellationToken CancellationToken The token to monitor for cancellation requests.

Returns — ValueTask. A ValueTask that represents the asynchronous operation.


MatchAsync(Func<T, CancellationToken, Task>?, Action?, CancellationToken)

public static async ValueTask MatchAsync<T>(this ValueTask<Optional<T>> receiver, Func<T, CancellationToken, Task>? some = null, Action? none = null, CancellationToken cancellationToken = default) where T : notnull

Asynchronously executes the delegate that matches the value of the current Optional<T> instance.

Type Parameters

Type Parameter Description
T The type of the underlying optional value.

Parameters

Parameter Type Description
receiver ValueTask<Optional<T>> The current ValueTask<Optional<T>> instance.
some Func<T, CancellationToken, Task>? The delegate to execute when the underlying value of the current Optional<T> instance is present.
none Action? The delegate to execute when the underlying value of the current Optional<T> instance is absent.
cancellationToken CancellationToken The token to monitor for cancellation requests.

Returns — ValueTask. A ValueTask that represents the asynchronous operation.


MatchAsync(Func<T, CancellationToken, ValueTask>?, Action?, CancellationToken)

public static async ValueTask MatchAsync<T>(this ValueTask<Optional<T>> receiver, Func<T, CancellationToken, ValueTask>? some = null, Action? none = null, CancellationToken cancellationToken = default) where T : notnull

Asynchronously executes the delegate that matches the value of the current Optional<T> instance.

Type Parameters

Type Parameter Description
T The type of the underlying optional value.

Parameters

Parameter Type Description
receiver ValueTask<Optional<T>> The current ValueTask<Optional<T>> instance.
some Func<T, CancellationToken, ValueTask>? The delegate to execute when the underlying value of the current Optional<T> instance is present.
none Action? The delegate to execute when the underlying value of the current Optional<T> instance is absent.
cancellationToken CancellationToken The token to monitor for cancellation requests.

Returns — ValueTask. A ValueTask that represents the asynchronous operation.


MatchAsync(Action<T>?, Func<Task>?, CancellationToken)

public static async ValueTask MatchAsync<T>(this ValueTask<Optional<T>> receiver, Action<T>? some = null, Func<Task>? none = null, CancellationToken cancellationToken = default) where T : notnull

Asynchronously executes the delegate that matches the value of the current Optional<T> instance.

Type Parameters

Type Parameter Description
T The type of the underlying optional value.

Parameters

Parameter Type Description
receiver ValueTask<Optional<T>> The current ValueTask<Optional<T>> instance.
some Action<T>? The delegate to execute when the underlying value of the current Optional<T> instance is present.
none Func<Task>? The delegate to execute when the underlying value of the current Optional<T> instance is absent.
cancellationToken CancellationToken The token to monitor for cancellation requests.

Returns — ValueTask. A ValueTask that represents the asynchronous operation.


MatchAsync(Action<T>?, Func<ValueTask>?, CancellationToken)

public static async ValueTask MatchAsync<T>(this ValueTask<Optional<T>> receiver, Action<T>? some = null, Func<ValueTask>? none = null, CancellationToken cancellationToken = default) where T : notnull

Asynchronously executes the delegate that matches the value of the current Optional<T> instance.

Type Parameters

Type Parameter Description
T The type of the underlying optional value.

Parameters

Parameter Type Description
receiver ValueTask<Optional<T>> The current ValueTask<Optional<T>> instance.
some Action<T>? The delegate to execute when the underlying value of the current Optional<T> instance is present.
none Func<ValueTask>? The delegate to execute when the underlying value of the current Optional<T> instance is absent.
cancellationToken CancellationToken The token to monitor for cancellation requests.

Returns — ValueTask. A ValueTask that represents the asynchronous operation.


MatchAsync(Action<T>?, Func<CancellationToken, Task>?, CancellationToken)

public static async ValueTask MatchAsync<T>(this ValueTask<Optional<T>> receiver, Action<T>? some = null, Func<CancellationToken, Task>? none = null, CancellationToken cancellationToken = default) where T : notnull

Asynchronously executes the delegate that matches the value of the current Optional<T> instance.

Type Parameters

Type Parameter Description
T The type of the underlying optional value.

Parameters

Parameter Type Description
receiver ValueTask<Optional<T>> The current ValueTask<Optional<T>> instance.
some Action<T>? The delegate to execute when the underlying value of the current Optional<T> instance is present.
none Func<CancellationToken, Task>? The delegate to execute when the underlying value of the current Optional<T> instance is absent.
cancellationToken CancellationToken The token to monitor for cancellation requests.

Returns — ValueTask. A ValueTask that represents the asynchronous operation.


MatchAsync(Action<T>?, Func<CancellationToken, ValueTask>?, CancellationToken)

public static async ValueTask MatchAsync<T>(this ValueTask<Optional<T>> receiver, Action<T>? some = null, Func<CancellationToken, ValueTask>? none = null, CancellationToken cancellationToken = default) where T : notnull

Asynchronously executes the delegate that matches the value of the current Optional<T> instance.

Type Parameters

Type Parameter Description
T The type of the underlying optional value.

Parameters

Parameter Type Description
receiver ValueTask<Optional<T>> The current ValueTask<Optional<T>> instance.
some Action<T>? The delegate to execute when the underlying value of the current Optional<T> instance is present.
none Func<CancellationToken, ValueTask>? The delegate to execute when the underlying value of the current Optional<T> instance is absent.
cancellationToken CancellationToken The token to monitor for cancellation requests.

Returns — ValueTask. A ValueTask that represents the asynchronous operation.


MatchAsync(Func<T, Task>?, Func<Task>?, CancellationToken)

public static async ValueTask MatchAsync<T>(this ValueTask<Optional<T>> receiver, Func<T, Task>? some = null, Func<Task>? none = null, CancellationToken cancellationToken = default) where T : notnull

Asynchronously executes the delegate that matches the value of the current Optional<T> instance.

Type Parameters

Type Parameter Description
T The type of the underlying optional value.

Parameters

Parameter Type Description
receiver ValueTask<Optional<T>> The current ValueTask<Optional<T>> instance.
some Func<T, Task>? The delegate to execute when the underlying value of the current Optional<T> instance is present.
none Func<Task>? The delegate to execute when the underlying value of the current Optional<T> instance is absent.
cancellationToken CancellationToken The token to monitor for cancellation requests.

Returns — ValueTask. A ValueTask that represents the asynchronous operation.


MatchAsync(Func<T, ValueTask>?, Func<ValueTask>?, CancellationToken)

public static async ValueTask MatchAsync<T>(this ValueTask<Optional<T>> receiver, Func<T, ValueTask>? some = null, Func<ValueTask>? none = null, CancellationToken cancellationToken = default) where T : notnull

Asynchronously executes the delegate that matches the value of the current Optional<T> instance.

Type Parameters

Type Parameter Description
T The type of the underlying optional value.

Parameters

Parameter Type Description
receiver ValueTask<Optional<T>> The current ValueTask<Optional<T>> instance.
some Func<T, ValueTask>? The delegate to execute when the underlying value of the current Optional<T> instance is present.
none Func<ValueTask>? The delegate to execute when the underlying value of the current Optional<T> instance is absent.
cancellationToken CancellationToken The token to monitor for cancellation requests.

Returns — ValueTask. A ValueTask that represents the asynchronous operation.


MatchAsync(Func<T, CancellationToken, Task>?, Func<CancellationToken, Task>?, CancellationToken)

public static async ValueTask MatchAsync<T>(this ValueTask<Optional<T>> receiver, Func<T, CancellationToken, Task>? some = null, Func<CancellationToken, Task>? none = null, CancellationToken cancellationToken = default) where T : notnull

Asynchronously executes the delegate that matches the value of the current Optional<T> instance.

Type Parameters

Type Parameter Description
T The type of the underlying optional value.

Parameters

Parameter Type Description
receiver ValueTask<Optional<T>> The current ValueTask<Optional<T>> instance.
some Func<T, CancellationToken, Task>? The delegate to execute when the underlying value of the current Optional<T> instance is present.
none Func<CancellationToken, Task>? The delegate to execute when the underlying value of the current Optional<T> instance is absent.
cancellationToken CancellationToken The token to monitor for cancellation requests.

Returns — ValueTask. A ValueTask that represents the asynchronous operation.


MatchAsync(Func<T, CancellationToken, ValueTask>?, Func<CancellationToken, ValueTask>?, CancellationToken)

public static async ValueTask MatchAsync<T>(this ValueTask<Optional<T>> receiver, Func<T, CancellationToken, ValueTask>? some = null, Func<CancellationToken, ValueTask>? none = null, CancellationToken cancellationToken = default) where T : notnull

Asynchronously executes the delegate that matches the value of the current Optional<T> instance.

Type Parameters

Type Parameter Description
T The type of the underlying optional value.

Parameters

Parameter Type Description
receiver ValueTask<Optional<T>> The current ValueTask<Optional<T>> instance.
some Func<T, CancellationToken, ValueTask>? The delegate to execute when the underlying value of the current Optional<T> instance is present.
none Func<CancellationToken, ValueTask>? The delegate to execute when the underlying value of the current Optional<T> instance is absent.
cancellationToken CancellationToken The token to monitor for cancellation requests.

Returns — ValueTask. A ValueTask that represents the asynchronous operation.


MatchAsync<TResult>(Func<T, TResult>, Func<TResult>, CancellationToken)

public static async ValueTask<TResult> MatchAsync<T, TResult>(this ValueTask<Optional<T>> receiver, Func<T, TResult> some, Func<TResult> none, CancellationToken cancellationToken = default) where T : notnull

Asynchronously executes the delegate that matches the value of the current Optional<T> instance and returns its result.

Type Parameters

Type Parameter Description
T The type of the underlying optional value.
TResult The underlying type of the result produced by the matching delegate.

Parameters

Parameter Type Description
receiver ValueTask<Optional<T>> The current ValueTask<Optional<T>> instance.
some Func<T, TResult> The delegate to execute when the underlying value of the current Optional<T> instance is present.
none Func<TResult> The delegate to execute when the underlying value of the current Optional<T> instance is absent.
cancellationToken CancellationToken The token to monitor for cancellation requests.

Returns — ValueTask<TResult>. The result of the some delegate if the underlying value of the current Optional<T> instance is present; otherwise, returns the result of the none delegate if the underlying value of the current Optional<T> instance is absent.


MatchAsync<TResult>(Func<T, Task<TResult>>, Func<TResult>, CancellationToken)

public static async ValueTask<TResult> MatchAsync<T, TResult>(this ValueTask<Optional<T>> receiver, Func<T, Task<TResult>> some, Func<TResult> none, CancellationToken cancellationToken = default) where T : notnull

Asynchronously executes the delegate that matches the value of the current Optional<T> instance and returns its result.

Type Parameters

Type Parameter Description
T The type of the underlying optional value.
TResult The underlying type of the result produced by the matching delegate.

Parameters

Parameter Type Description
receiver ValueTask<Optional<T>> The current ValueTask<Optional<T>> instance.
some Func<T, Task<TResult>> The delegate to execute when the underlying value of the current Optional<T> instance is present.
none Func<TResult> The delegate to execute when the underlying value of the current Optional<T> instance is absent.
cancellationToken CancellationToken The token to monitor for cancellation requests.

Returns — ValueTask<TResult>. The result of the some delegate if the underlying value of the current Optional<T> instance is present; otherwise, returns the result of the none delegate if the underlying value of the current Optional<T> instance is absent.


MatchAsync<TResult>(Func<T, ValueTask<TResult>>, Func<TResult>, CancellationToken)

public static async ValueTask<TResult> MatchAsync<T, TResult>(this ValueTask<Optional<T>> receiver, Func<T, ValueTask<TResult>> some, Func<TResult> none, CancellationToken cancellationToken = default) where T : notnull

Asynchronously executes the delegate that matches the value of the current Optional<T> instance and returns its result.

Type Parameters

Type Parameter Description
T The type of the underlying optional value.
TResult The underlying type of the result produced by the matching delegate.

Parameters

Parameter Type Description
receiver ValueTask<Optional<T>> The current ValueTask<Optional<T>> instance.
some Func<T, ValueTask<TResult>> The delegate to execute when the underlying value of the current Optional<T> instance is present.
none Func<TResult> The delegate to execute when the underlying value of the current Optional<T> instance is absent.
cancellationToken CancellationToken The token to monitor for cancellation requests.

Returns — ValueTask<TResult>. The result of the some delegate if the underlying value of the current Optional<T> instance is present; otherwise, returns the result of the none delegate if the underlying value of the current Optional<T> instance is absent.


MatchAsync<TResult>(Func<T, CancellationToken, Task<TResult>>, Func<TResult>, CancellationToken)

public static async ValueTask<TResult> MatchAsync<T, TResult>(this ValueTask<Optional<T>> receiver, Func<T, CancellationToken, Task<TResult>> some, Func<TResult> none, CancellationToken cancellationToken = default) where T : notnull

Asynchronously executes the delegate that matches the value of the current Optional<T> instance and returns its result.

Type Parameters

Type Parameter Description
T The type of the underlying optional value.
TResult The underlying type of the result produced by the matching delegate.

Parameters

Parameter Type Description
receiver ValueTask<Optional<T>> The current ValueTask<Optional<T>> instance.
some Func<T, CancellationToken, Task<TResult>> The delegate to execute when the underlying value of the current Optional<T> instance is present.
none Func<TResult> The delegate to execute when the underlying value of the current Optional<T> instance is absent.
cancellationToken CancellationToken The token to monitor for cancellation requests.

Returns — ValueTask<TResult>. The result of the some delegate if the underlying value of the current Optional<T> instance is present; otherwise, returns the result of the none delegate if the underlying value of the current Optional<T> instance is absent.


MatchAsync<TResult>(Func<T, CancellationToken, ValueTask<TResult>>, Func<TResult>, CancellationToken)

public static async ValueTask<TResult> MatchAsync<T, TResult>(this ValueTask<Optional<T>> receiver, Func<T, CancellationToken, ValueTask<TResult>> some, Func<TResult> none, CancellationToken cancellationToken = default) where T : notnull

Asynchronously executes the delegate that matches the value of the current Optional<T> instance and returns its result.

Type Parameters

Type Parameter Description
T The type of the underlying optional value.
TResult The underlying type of the result produced by the matching delegate.

Parameters

Parameter Type Description
receiver ValueTask<Optional<T>> The current ValueTask<Optional<T>> instance.
some Func<T, CancellationToken, ValueTask<TResult>> The delegate to execute when the underlying value of the current Optional<T> instance is present.
none Func<TResult> The delegate to execute when the underlying value of the current Optional<T> instance is absent.
cancellationToken CancellationToken The token to monitor for cancellation requests.

Returns — ValueTask<TResult>. The result of the some delegate if the underlying value of the current Optional<T> instance is present; otherwise, returns the result of the none delegate if the underlying value of the current Optional<T> instance is absent.


MatchAsync<TResult>(Func<T, TResult>, Func<Task<TResult>>, CancellationToken)

public static async ValueTask<TResult> MatchAsync<T, TResult>(this ValueTask<Optional<T>> receiver, Func<T, TResult> some, Func<Task<TResult>> none, CancellationToken cancellationToken = default) where T : notnull

Asynchronously executes the delegate that matches the value of the current Optional<T> instance and returns its result.

Type Parameters

Type Parameter Description
T The type of the underlying optional value.
TResult The underlying type of the result produced by the matching delegate.

Parameters

Parameter Type Description
receiver ValueTask<Optional<T>> The current ValueTask<Optional<T>> instance.
some Func<T, TResult> The delegate to execute when the underlying value of the current Optional<T> instance is present.
none Func<Task<TResult>> The delegate to execute when the underlying value of the current Optional<T> instance is absent.
cancellationToken CancellationToken The token to monitor for cancellation requests.

Returns — ValueTask<TResult>. The result of the some delegate if the underlying value of the current Optional<T> instance is present; otherwise, returns the result of the none delegate if the underlying value of the current Optional<T> instance is absent.


MatchAsync<TResult>(Func<T, TResult>, Func<ValueTask<TResult>>, CancellationToken)

public static async ValueTask<TResult> MatchAsync<T, TResult>(this ValueTask<Optional<T>> receiver, Func<T, TResult> some, Func<ValueTask<TResult>> none, CancellationToken cancellationToken = default) where T : notnull

Asynchronously executes the delegate that matches the value of the current Optional<T> instance and returns its result.

Type Parameters

Type Parameter Description
T The type of the underlying optional value.
TResult The underlying type of the result produced by the matching delegate.

Parameters

Parameter Type Description
receiver ValueTask<Optional<T>> The current ValueTask<Optional<T>> instance.
some Func<T, TResult> The delegate to execute when the underlying value of the current Optional<T> instance is present.
none Func<ValueTask<TResult>> The delegate to execute when the underlying value of the current Optional<T> instance is absent.
cancellationToken CancellationToken The token to monitor for cancellation requests.

Returns — ValueTask<TResult>. The result of the some delegate if the underlying value of the current Optional<T> instance is present; otherwise, returns the result of the none delegate if the underlying value of the current Optional<T> instance is absent.


MatchAsync<TResult>(Func<T, TResult>, Func<CancellationToken, Task<TResult>>, CancellationToken)

public static async ValueTask<TResult> MatchAsync<T, TResult>(this ValueTask<Optional<T>> receiver, Func<T, TResult> some, Func<CancellationToken, Task<TResult>> none, CancellationToken cancellationToken = default) where T : notnull

Asynchronously executes the delegate that matches the value of the current Optional<T> instance and returns its result.

Type Parameters

Type Parameter Description
T The type of the underlying optional value.
TResult The underlying type of the result produced by the matching delegate.

Parameters

Parameter Type Description
receiver ValueTask<Optional<T>> The current ValueTask<Optional<T>> instance.
some Func<T, TResult> The delegate to execute when the underlying value of the current Optional<T> instance is present.
none Func<CancellationToken, Task<TResult>> The delegate to execute when the underlying value of the current Optional<T> instance is absent.
cancellationToken CancellationToken The token to monitor for cancellation requests.

Returns — ValueTask<TResult>. The result of the some delegate if the underlying value of the current Optional<T> instance is present; otherwise, returns the result of the none delegate if the underlying value of the current Optional<T> instance is absent.


MatchAsync<TResult>(Func<T, TResult>, Func<CancellationToken, ValueTask<TResult>>, CancellationToken)

public static async ValueTask<TResult> MatchAsync<T, TResult>(this ValueTask<Optional<T>> receiver, Func<T, TResult> some, Func<CancellationToken, ValueTask<TResult>> none, CancellationToken cancellationToken = default) where T : notnull

Asynchronously executes the delegate that matches the value of the current Optional<T> instance and returns its result.

Type Parameters

Type Parameter Description
T The type of the underlying optional value.
TResult The underlying type of the result produced by the matching delegate.

Parameters

Parameter Type Description
receiver ValueTask<Optional<T>> The current ValueTask<Optional<T>> instance.
some Func<T, TResult> The delegate to execute when the underlying value of the current Optional<T> instance is present.
none Func<CancellationToken, ValueTask<TResult>> The delegate to execute when the underlying value of the current Optional<T> instance is absent.
cancellationToken CancellationToken The token to monitor for cancellation requests.

Returns — ValueTask<TResult>. The result of the some delegate if the underlying value of the current Optional<T> instance is present; otherwise, returns the result of the none delegate if the underlying value of the current Optional<T> instance is absent.


MatchAsync<TResult>(Func<T, Task<TResult>>, Func<Task<TResult>>, CancellationToken)

public static async ValueTask<TResult> MatchAsync<T, TResult>(this ValueTask<Optional<T>> receiver, Func<T, Task<TResult>> some, Func<Task<TResult>> none, CancellationToken cancellationToken = default) where T : notnull

Asynchronously executes the delegate that matches the value of the current Optional<T> instance and returns its result.

Type Parameters

Type Parameter Description
T The type of the underlying optional value.
TResult The underlying type of the result produced by the matching delegate.

Parameters

Parameter Type Description
receiver ValueTask<Optional<T>> The current ValueTask<Optional<T>> instance.
some Func<T, Task<TResult>> The delegate to execute when the underlying value of the current Optional<T> instance is present.
none Func<Task<TResult>> The delegate to execute when the underlying value of the current Optional<T> instance is absent.
cancellationToken CancellationToken The token to monitor for cancellation requests.

Returns — ValueTask<TResult>. The result of the some delegate if the underlying value of the current Optional<T> instance is present; otherwise, returns the result of the none delegate if the underlying value of the current Optional<T> instance is absent.


MatchAsync<TResult>(Func<T, ValueTask<TResult>>, Func<ValueTask<TResult>>, CancellationToken)

public static async ValueTask<TResult> MatchAsync<T, TResult>(this ValueTask<Optional<T>> receiver, Func<T, ValueTask<TResult>> some, Func<ValueTask<TResult>> none, CancellationToken cancellationToken = default) where T : notnull

Asynchronously executes the delegate that matches the value of the current Optional<T> instance and returns its result.

Type Parameters

Type Parameter Description
T The type of the underlying optional value.
TResult The underlying type of the result produced by the matching delegate.

Parameters

Parameter Type Description
receiver ValueTask<Optional<T>> The current ValueTask<Optional<T>> instance.
some Func<T, ValueTask<TResult>> The delegate to execute when the underlying value of the current Optional<T> instance is present.
none Func<ValueTask<TResult>> The delegate to execute when the underlying value of the current Optional<T> instance is absent.
cancellationToken CancellationToken The token to monitor for cancellation requests.

Returns — ValueTask<TResult>. The result of the some delegate if the underlying value of the current Optional<T> instance is present; otherwise, returns the result of the none delegate if the underlying value of the current Optional<T> instance is absent.


MatchAsync<TResult>(Func<T, CancellationToken, Task<TResult>>, Func<CancellationToken, Task<TResult>>, CancellationToken)

public static async ValueTask<TResult> MatchAsync<T, TResult>(this ValueTask<Optional<T>> receiver, Func<T, CancellationToken, Task<TResult>> some, Func<CancellationToken, Task<TResult>> none, CancellationToken cancellationToken = default) where T : notnull

Asynchronously executes the delegate that matches the value of the current Optional<T> instance and returns its result.

Type Parameters

Type Parameter Description
T The type of the underlying optional value.
TResult The underlying type of the result produced by the matching delegate.

Parameters

Parameter Type Description
receiver ValueTask<Optional<T>> The current ValueTask<Optional<T>> instance.
some Func<T, CancellationToken, Task<TResult>> The delegate to execute when the underlying value of the current Optional<T> instance is present.
none Func<CancellationToken, Task<TResult>> The delegate to execute when the underlying value of the current Optional<T> instance is absent.
cancellationToken CancellationToken The token to monitor for cancellation requests.

Returns — ValueTask<TResult>. The result of the some delegate if the underlying value of the current Optional<T> instance is present; otherwise, returns the result of the none delegate if the underlying value of the current Optional<T> instance is absent.


MatchAsync<TResult>(Func<T, CancellationToken, ValueTask<TResult>>, Func<CancellationToken, ValueTask<TResult>>, CancellationToken)

public static async ValueTask<TResult> MatchAsync<T, TResult>(this ValueTask<Optional<T>> receiver, Func<T, CancellationToken, ValueTask<TResult>> some, Func<CancellationToken, ValueTask<TResult>> none, CancellationToken cancellationToken = default) where T : notnull

Asynchronously executes the delegate that matches the value of the current Optional<T> instance and returns its result.

Type Parameters

Type Parameter Description
T The type of the underlying optional value.
TResult The underlying type of the result produced by the matching delegate.

Parameters

Parameter Type Description
receiver ValueTask<Optional<T>> The current ValueTask<Optional<T>> instance.
some Func<T, CancellationToken, ValueTask<TResult>> The delegate to execute when the underlying value of the current Optional<T> instance is present.
none Func<CancellationToken, ValueTask<TResult>> The delegate to execute when the underlying value of the current Optional<T> instance is absent.
cancellationToken CancellationToken The token to monitor for cancellation requests.

Returns — ValueTask<TResult>. The result of the some delegate if the underlying value of the current Optional<T> instance is present; otherwise, returns the result of the none delegate if the underlying value of the current Optional<T> instance is absent.


SelectAsync<TResult>(Func<T, TResult>, CancellationToken)

public static async ValueTask<Optional<TResult>> SelectAsync<T, TResult>(this ValueTask<Optional<T>> receiver, Func<T, TResult> selector, CancellationToken cancellationToken = default) where T : notnull where TResult : notnull

Asynchronously applies the provided selector delegate to the value of the current Optional<T> instance.

Type Parameters

Type Parameter Description
T The type of the underlying optional value.
TResult The underlying type of the result produced by the selector delegate.

Parameters

Parameter Type Description
receiver ValueTask<Optional<T>> The current ValueTask<Optional<T>> instance.
selector Func<T, TResult> The delegate to apply to the value of the current Optional<T> instance.
cancellationToken CancellationToken The token to monitor for cancellation requests.

Returns — ValueTask<Optional<TResult>>. A new Optional<TResult> instance containing the result of the delegate if the current Optional<T> instance has an underlying value; otherwise, Optional<TResult>.None.


SelectAsync<TResult>(Func<T, Task<TResult>>, CancellationToken)

public static async ValueTask<Optional<TResult>> SelectAsync<T, TResult>(this ValueTask<Optional<T>> receiver, Func<T, Task<TResult>> selector, CancellationToken cancellationToken = default) where T : notnull where TResult : notnull

Asynchronously applies the provided selector delegate to the value of the current Optional<T> instance.

Type Parameters

Type Parameter Description
T The type of the underlying optional value.
TResult The underlying type of the result produced by the selector delegate.

Parameters

Parameter Type Description
receiver ValueTask<Optional<T>> The current ValueTask<Optional<T>> instance.
selector Func<T, Task<TResult>> The delegate to apply to the value of the current Optional<T> instance.
cancellationToken CancellationToken The token to monitor for cancellation requests.

Returns — ValueTask<Optional<TResult>>. A new Optional<TResult> instance containing the result of the delegate if the current Optional<T> instance has an underlying value; otherwise, Optional<TResult>.None.


SelectAsync<TResult>(Func<T, ValueTask<TResult>>, CancellationToken)

public static async ValueTask<Optional<TResult>> SelectAsync<T, TResult>(this ValueTask<Optional<T>> receiver, Func<T, ValueTask<TResult>> selector, CancellationToken cancellationToken = default) where T : notnull where TResult : notnull

Asynchronously applies the provided selector delegate to the value of the current Optional<T> instance.

Type Parameters

Type Parameter Description
T The type of the underlying optional value.
TResult The underlying type of the result produced by the selector delegate.

Parameters

Parameter Type Description
receiver ValueTask<Optional<T>> The current ValueTask<Optional<T>> instance.
selector Func<T, ValueTask<TResult>> The delegate to apply to the value of the current Optional<T> instance.
cancellationToken CancellationToken The token to monitor for cancellation requests.

Returns — ValueTask<Optional<TResult>>. A new Optional<TResult> instance containing the result of the delegate if the current Optional<T> instance has an underlying value; otherwise, Optional<TResult>.None.


SelectAsync<TResult>(Func<T, CancellationToken, Task<TResult>>, CancellationToken)

public static async ValueTask<Optional<TResult>> SelectAsync<T, TResult>(this ValueTask<Optional<T>> receiver, Func<T, CancellationToken, Task<TResult>> selector, CancellationToken cancellationToken = default) where T : notnull where TResult : notnull

Asynchronously applies the provided selector delegate to the value of the current Optional<T> instance.

Type Parameters

Type Parameter Description
T The type of the underlying optional value.
TResult The underlying type of the result produced by the selector delegate.

Parameters

Parameter Type Description
receiver ValueTask<Optional<T>> The current ValueTask<Optional<T>> instance.
selector Func<T, CancellationToken, Task<TResult>> The delegate to apply to the value of the current Optional<T> instance.
cancellationToken CancellationToken The token to monitor for cancellation requests.

Returns — ValueTask<Optional<TResult>>. A new Optional<TResult> instance containing the result of the delegate if the current Optional<T> instance has an underlying value; otherwise, Optional<TResult>.None.


SelectAsync<TResult>(Func<T, CancellationToken, ValueTask<TResult>>, CancellationToken)

public static async ValueTask<Optional<TResult>> SelectAsync<T, TResult>(this ValueTask<Optional<T>> receiver, Func<T, CancellationToken, ValueTask<TResult>> selector, CancellationToken cancellationToken = default) where T : notnull where TResult : notnull

Asynchronously applies the provided selector delegate to the value of the current Optional<T> instance.

Type Parameters

Type Parameter Description
T The type of the underlying optional value.
TResult The underlying type of the result produced by the selector delegate.

Parameters

Parameter Type Description
receiver ValueTask<Optional<T>> The current ValueTask<Optional<T>> instance.
selector Func<T, CancellationToken, ValueTask<TResult>> The delegate to apply to the value of the current Optional<T> instance.
cancellationToken CancellationToken The token to monitor for cancellation requests.

Returns — ValueTask<Optional<TResult>>. A new Optional<TResult> instance containing the result of the delegate if the current Optional<T> instance has an underlying value; otherwise, Optional<TResult>.None.


SelectManyAsync<TResult>(Func<T, Optional<TResult>>, CancellationToken)

public static async ValueTask<Optional<TResult>> SelectManyAsync<T, TResult>(this ValueTask<Optional<T>> receiver, Func<T, Optional<TResult>> selector, CancellationToken cancellationToken = default) where T : notnull where TResult : notnull

Asynchronously applies the provided selector delegate to the value of the current Optional<T> instance.

Type Parameters

Type Parameter Description
T The type of the underlying optional value.
TResult The underlying type of the result produced by the selector delegate.

Parameters

Parameter Type Description
receiver ValueTask<Optional<T>> The current ValueTask<Optional<T>> instance.
selector Func<T, Optional<TResult>> The delegate to apply to the value of the current Optional<T> instance.
cancellationToken CancellationToken The token to monitor for cancellation requests.

Returns — ValueTask<Optional<TResult>>. A new Optional<TResult> instance containing the result of the delegate if the current Optional<T> instance has an underlying value; otherwise, Optional<TResult>.None.


SelectManyAsync<TResult>(Func<T, Task<Optional<TResult>>>, CancellationToken)

public static async ValueTask<Optional<TResult>> SelectManyAsync<T, TResult>(this ValueTask<Optional<T>> receiver, Func<T, Task<Optional<TResult>>> selector, CancellationToken cancellationToken = default) where T : notnull where TResult : notnull

Asynchronously applies the provided selector delegate to the value of the current Optional<T> instance.

Type Parameters

Type Parameter Description
T The type of the underlying optional value.
TResult The underlying type of the result produced by the selector delegate.

Parameters

Parameter Type Description
receiver ValueTask<Optional<T>> The current ValueTask<Optional<T>> instance.
selector Func<T, Task<Optional<TResult>>> The delegate to apply to the value of the current Optional<T> instance.
cancellationToken CancellationToken The token to monitor for cancellation requests.

Returns — ValueTask<Optional<TResult>>. A new Optional<TResult> instance containing the result of the delegate if the current Optional<T> instance has an underlying value; otherwise, Optional<TResult>.None.


SelectManyAsync<TResult>(Func<T, ValueTask<Optional<TResult>>>, CancellationToken)

public static async ValueTask<Optional<TResult>> SelectManyAsync<T, TResult>(this ValueTask<Optional<T>> receiver, Func<T, ValueTask<Optional<TResult>>> selector, CancellationToken cancellationToken = default) where T : notnull where TResult : notnull

Asynchronously applies the provided selector delegate to the value of the current Optional<T> instance.

Type Parameters

Type Parameter Description
T The type of the underlying optional value.
TResult The underlying type of the result produced by the selector delegate.

Parameters

Parameter Type Description
receiver ValueTask<Optional<T>> The current ValueTask<Optional<T>> instance.
selector Func<T, ValueTask<Optional<TResult>>> The delegate to apply to the value of the current Optional<T> instance.
cancellationToken CancellationToken The token to monitor for cancellation requests.

Returns — ValueTask<Optional<TResult>>. A new Optional<TResult> instance containing the result of the delegate if the current Optional<T> instance has an underlying value; otherwise, Optional<TResult>.None.


SelectManyAsync<TResult>(Func<T, CancellationToken, Task<Optional<TResult>>>, CancellationToken)

public static async ValueTask<Optional<TResult>> SelectManyAsync<T, TResult>(this ValueTask<Optional<T>> receiver, Func<T, CancellationToken, Task<Optional<TResult>>> selector, CancellationToken cancellationToken = default) where T : notnull where TResult : notnull

Asynchronously applies the provided selector delegate to the value of the current Optional<T> instance.

Type Parameters

Type Parameter Description
T The type of the underlying optional value.
TResult The underlying type of the result produced by the selector delegate.

Parameters

Parameter Type Description
receiver ValueTask<Optional<T>> The current ValueTask<Optional<T>> instance.
selector Func<T, CancellationToken, Task<Optional<TResult>>> The delegate to apply to the value of the current Optional<T> instance.
cancellationToken CancellationToken The token to monitor for cancellation requests.

Returns — ValueTask<Optional<TResult>>. A new Optional<TResult> instance containing the result of the delegate if the current Optional<T> instance has an underlying value; otherwise, Optional<TResult>.None.


SelectManyAsync<TResult>(Func<T, CancellationToken, ValueTask<Optional<TResult>>>, CancellationToken)

public static async ValueTask<Optional<TResult>> SelectManyAsync<T, TResult>(this ValueTask<Optional<T>> receiver, Func<T, CancellationToken, ValueTask<Optional<TResult>>> selector, CancellationToken cancellationToken = default) where T : notnull where TResult : notnull

Asynchronously applies the provided selector delegate to the value of the current Optional<T> instance.

Type Parameters

Type Parameter Description
T The type of the underlying optional value.
TResult The underlying type of the result produced by the selector delegate.

Parameters

Parameter Type Description
receiver ValueTask<Optional<T>> The current ValueTask<Optional<T>> instance.
selector Func<T, CancellationToken, ValueTask<Optional<TResult>>> The delegate to apply to the value of the current Optional<T> instance.
cancellationToken CancellationToken The token to monitor for cancellation requests.

Returns — ValueTask<Optional<TResult>>. A new Optional<TResult> instance containing the result of the delegate if the current Optional<T> instance has an underlying value; otherwise, Optional<TResult>.None.


ToResultAsync(CancellationToken)

public static async ValueTask<Result<Optional<T>>> ToResultAsync<T>(this ValueTask<Optional<T>> receiver, CancellationToken cancellationToken = default) where T : notnull

Asynchronously wraps the current Optional<T> instance into new, successful Result<T> instance.

Type Parameters

Type Parameter Description
T The type of the underlying optional value.

Parameters

Parameter Type Description
receiver ValueTask<Optional<T>> The current ValueTask<Optional<T>> instance.
cancellationToken CancellationToken The token to monitor for cancellation requests.

Returns — ValueTask<Result<Optional<T>>>. A new, successful Result<T> instance containing the current Optional<T> instance.


See Also

ONIXLabs .NET Library


Clone this wiki locally