Class
EnumerableOption<T>
class EnumerableOption<T>
Namespace: System.Linq
Assembly: Raven.Core.dll
Source file: LinqExtensions.rvn
Inheritance: object → EnumerableOption<T>
Provides Option- and Result-returning sequence operations.
Type parameters
| Name | Description |
|---|---|
T |
The sequence element type. |
Methods
26 items
static func ElementAtOrError<T, E>(self: IEnumerable<T>, index: int, errorFactory: () -> E) -> Result<T, E>
Returns the element at `index` as `Ok`, or an error when the index is out of range.
static func ElementAtOrNone<T>(self: IEnumerable<T>, index: int) -> Option<T>
Returns the element at `index` as `Some`, or `None` when the index is out of range.
static func FirstOrError<T, E>(self: IEnumerable<T>, errorFactory: () -> E) -> Result<T, E>
Returns the first element as `Ok`, or an error produced by `errorFactory`.
static func FirstOrError<T, E>(self: IEnumerable<T>, predicate: T -> bool, errorFactory: () -> E) -> Result<T, E>
Returns the first matching element as `Ok`, or an error produced by `errorFactory`.
static func FirstOrNone<T>(self: IEnumerable<T>, predicate: T -> bool) -> Option<T>
Returns the first matching element as `Some`, or `None` when no element matches.
static func FirstOrNone<T>(self: IEnumerable<T>) -> Option<T>
Returns the first element as `Some`, or `None` for an empty sequence.
static func LastOrError<T, E>(self: IEnumerable<T>, errorFactory: () -> E) -> Result<T, E>
Returns the last element as `Ok`, or an error produced by `errorFactory`.
static func LastOrError<T, E>(self: IEnumerable<T>, predicate: T -> bool, errorFactory: () -> E) -> Result<T, E>
Returns the last matching element as `Ok`, or an error produced by `errorFactory`.
static func LastOrNone<T>(self: IEnumerable<T>, predicate: T -> bool) -> Option<T>
Returns the last matching element as `Some`, or `None` when no element matches.
static func LastOrNone<T>(self: IEnumerable<T>) -> Option<T>
Returns the last element as `Some`, or `None` for an empty sequence.
static func SingleOrError<T, E>(self: IEnumerable<T>, errorFactory: () -> E) -> Result<T, E>
Returns the only element as `Ok`, or an error unless exactly one element exists.
static func SingleOrError<T, E>(self: IEnumerable<T>, errorIfNone: () -> E, errorIfMany: () -> E) -> Result<T, E>
Returns the only element as `Ok`, distinguishing empty and multiple-element errors.
static func SingleOrError<T, E>(self: IEnumerable<T>, predicate: T -> bool, errorFactory: () -> E) -> Result<T, E>
Returns the only matching element as `Ok`, or an error unless exactly one element matches.
static func SingleOrError<T, E>(self: IEnumerable<T>, predicate: T -> bool, errorIfNone: () -> E, errorIfMany: () -> E) -> Result<T, E>
Returns the only matching element as `Ok`, distinguishing no-match and multiple-match errors.
static func SingleOrNone<T>(self: IEnumerable<T>, predicate: T -> bool) -> Option<T>
Returns the only matching element as `Some`, or `None` unless exactly one element matches.
static func SingleOrNone<T>(self: IEnumerable<T>) -> Option<T>
Returns the only element as `Some`, or `None` unless exactly one element exists.
static func ToArrayOrError<T, E>(self: IEnumerable<T>, errorFactory: Exception -> E) -> Result<T[], E>
Materializes the sequence as an array and maps any exception to an error.
static func ToArrayOrException<T>(self: IEnumerable<T>) -> Result<T[], Exception>
Materializes the sequence as an array and captures any exception as an error.
static func ToDictionaryOrError<T, TKey, E>(self: IEnumerable<T>, keySelector: T -> TKey, errorFactory: Exception -> E) -> Result<Dictionary<TKey, T>, E>
Materializes the sequence as a dictionary and maps any exception to an error.
static func ToDictionaryOrError<T, TKey, TValue, E>(self: IEnumerable<T>, keySelector: T -> TKey, elementSelector: T -> TValue, errorFactory: Exception -> E) -> Result<Dictionary<TKey, TValue>, E>
Materializes projected elements as a dictionary and maps any exception to an error.
static func ToDictionaryOrException<T, TKey, TValue>(self: IEnumerable<T>, keySelector: T -> TKey, elementSelector: T -> TValue) -> Result<Dictionary<TKey, TValue>, Exception>
Materializes projected elements as a dictionary and captures any exception as an error.
static func ToDictionaryOrException<T, TKey>(self: IEnumerable<T>, keySelector: T -> TKey) -> Result<Dictionary<TKey, T>, Exception>
Materializes the sequence as a dictionary and captures any exception as an error.
static func ToHashSetOrError<T, E>(self: IEnumerable<T>, errorFactory: Exception -> E) -> Result<HashSet<T>, E>
Materializes the sequence as a hash set and maps any exception to an error.
static func ToHashSetOrException<T>(self: IEnumerable<T>) -> Result<HashSet<T>, Exception>
Materializes the sequence as a hash set and captures any exception as an error.
static func ToListOrError<T, E>(self: IEnumerable<T>, errorFactory: Exception -> E) -> Result<List<T>, E>
Materializes the sequence as a list and maps any exception to an error.
static func ToListOrException<T>(self: IEnumerable<T>) -> Result<List<T>, Exception>
Materializes the sequence as a list and captures any exception as an error.