Ejemplo n.º 1
0
 public static ValueTask <Option <TResult, TException> > MapAsync <T, TException, TResult>(this ValueTask <Option <T, TException> > option, Func <T, ValueTask <TResult> > mapping) =>
 option.MatchAsync(
     some: async val => (await mapping(val)).Some <TResult, TException>(),
     none: err => new ValueTask <Option <TResult, TException> >(Option.None <TResult, TException>(err)));
Ejemplo n.º 2
0
 public static ValueTask <Option <T, TExceptionResult> > MapExceptionAsync <T, TException, TExceptionResult>(this ValueTask <Option <T, TException> > optionValueTask, Func <TException, ValueTask <TExceptionResult> > mapping) =>
 optionValueTask.MatchAsync(
     some: val => new ValueTask <Option <T, TExceptionResult> >(Option.Some <T, TExceptionResult>(val)),
     none: async err => Option.None <T, TExceptionResult>(await mapping(err)));
Ejemplo n.º 3
0
 public static ValueTask <Option <TResult> > FlatMapAsync <T, TResult>(this ValueTask <Option <T> > option, Func <T, ValueTask <Option <TResult> > > mapping) =>
 option.MatchAsync(
     some: async val => (await mapping(val)),
     none: () => new ValueTask <Option <TResult> >(Option.None <TResult>()));