ResultSelector_Overload__Flattening_From_String_Maybe_With_value_To_String_Maybe_Without_Value__Expects_String_Maybe_Without_Value() { const string input = "hello"; await AsyncMaybe.Value(input) .FlatMapAsync(x => AsyncMaybe.None <string>(), (x, y) => x.Length + y.Length); }
Flattening_From_String_Maybe_With_value_To_String_Maybe_Without_Value__Expects_String_Maybe_Without_Value() { const string input = "hello"; await AsyncMaybe.Value(input) .FlatMapAsync(x => AsyncMaybe.None <int>()) .AssertNone(); }
public static AsyncMaybe <T> Flatten <T>(this AsyncMaybe <Maybe <T> > source) { var t = source.Match <AsyncMaybe <T> >( some: outerValue => new AsyncMaybe <T>(Task.FromResult <Maybe <T> >(outerValue)), none: none => AsyncMaybe <T> .None() ); return(t.ToAsyncMaybe()); }
ResultSelector_Overload__Flattening_From_String_Maybe_Without_value_To_Nullable_Int_With_Value__Expects_String_Maybe_Without_Value() { int?nullableInt = 2; await AsyncMaybe.None <string>() .FlatMapAsync(async x => { await AssertionUtilities.Delay; return(nullableInt); }, (x, y) => x.Length + y) .AssertNone(); }
ResultSelector_Overload__Flattening_From_String_Maybe_Without_value_To_String_Maybe_Without_Value__Expects_String_Maybe_Without_Value() { await AsyncMaybe.None <string>() .FlatMapAsync(x => AsyncMaybe.None <string>()) .AssertNone(); }
public static AsyncMaybe <TResult> FlatMapAsync <T, TResult>( this AsyncMaybe <T> source, [NotNull] Func <T, Task <AsyncMaybe <TResult> > > mapper) { return(source.Match(mapper, none => AsyncMaybe <TResult> .None()).ToAsyncMaybe()); }
public static AsyncMaybe <T> ToAsyncMaybe <T>(this None none) { return(AsyncMaybe <T> .None()); }