示例#1
0
 public static IOption <T> TryParse <T>(string str, ParserDelegate <T> parser) =>
 parser(str, out var perhapsResult) ? Some.Of(perhapsResult) : new None <T>();
示例#2
0
 public static IOption <TElem> TryKey <TKey, TElem>(TKey key, IDictionary <TKey, TElem> dict) =>
 dict.ContainsKey(key) ? Some.Of(dict[key]) : new None <TElem>();
示例#3
0
 public static IOption <T> FromMaybeNull <T>(T value) where T : class =>
 value != null?Some.Of(value) : new None <T>();
示例#4
0
 public static IOption <TElem> TryFind <TElem>(IEnumerable <TElem> values, Func <TElem, bool> predicate) =>
 values.Any(predicate) ? Some.Of(values.First(predicate)) : new None <TElem>();
示例#5
0
 public static IOption <T> FromNullable <T>(T?value) where T : struct =>
 value.HasValue ? Some.Of(value.Value) : new None <T>();