Пример #1
0
 public static Option <T> OrElse <T>(this Option <T> option, Func <Option <T> > func)
 {
     if (func == null)
     {
         throw new ArgumentNullException(nameof(func));
     }
     return(option.Intent(out _) is OptionData.Some ? option : func.Invoke());
 }
Пример #2
0
 public static bool IsNone <T>(this Option <T> option)
 {
     return(option.Intent(out _) is OptionData.None);
 }
Пример #3
0
 public static Option <T> Xor <T>(this Option <T> option, Option <T> other)
 {
     return(option.Intent(out _) is OptionData.Some
         ? other.Intent(out _) is OptionData.Some ? Option <T> .None() : option
         : other.Intent(out _) is OptionData.Some ? other : Option <T> .None());
 }
Пример #4
0
 public static Option <T> Or <T>(this Option <T> option, Option <T> other)
 {
     return(option.Intent(out _) is OptionData.Some ? option : other);
 }
Пример #5
0
 public static Option <U> And <T, U>(this Option <T> option, Option <U> other)
 {
     return(option.Intent(out _) is OptionData.Some ? other : Option <U> .None());
 }