SingleOrError
Declaring type: EnumerableOption<T>
Namespace: System.Linq
Assembly: Raven.Core.dll
Source file: LinqExtensions.rvn
Overloads / Variants
SingleOrError
func SingleOrError<T, E>(errorFactory: () -> E) -> Result<T, E>
Source file: LinqExtensions.rvn
Extension from EnumerableOption<T>.SingleOrError
Returns the only element as Ok, or an error unless exactly one element exists.
Parameters
| Name | Type | Description |
|---|---|---|
self |
IEnumerable<T> | |
errorFactory |
() -> E |
Return value
Result<T, E>
SingleOrError
func SingleOrError<T, E>(errorIfNone: () -> E, errorIfMany: () -> E) -> Result<T, E>
Source file: LinqExtensions.rvn
Extension from EnumerableOption<T>.SingleOrError
Returns the only element as Ok, distinguishing empty and multiple-element errors.
Parameters
| Name | Type | Description |
|---|---|---|
self |
IEnumerable<T> | |
errorIfNone |
() -> E | |
errorIfMany |
() -> E |
Return value
Result<T, E>
SingleOrError
func SingleOrError<T, E>(predicate: T -> bool, errorFactory: () -> E) -> Result<T, E>
Source file: LinqExtensions.rvn
Extension from EnumerableOption<T>.SingleOrError
Returns the only matching element as Ok, or an error unless exactly one element matches.
Parameters
| Name | Type | Description |
|---|---|---|
self |
IEnumerable<T> | |
predicate |
T -> Boolean | |
errorFactory |
() -> E |
Return value
Result<T, E>
SingleOrError
func SingleOrError<T, E>(predicate: T -> bool, errorIfNone: () -> E, errorIfMany: () -> E) -> Result<T, E>
Source file: LinqExtensions.rvn
Extension from EnumerableOption<T>.SingleOrError
Returns the only matching element as Ok, distinguishing no-match and multiple-match errors.
Parameters
| Name | Type | Description |
|---|---|---|
self |
IEnumerable<T> | |
predicate |
T -> Boolean | |
errorIfNone |
() -> E | |
errorIfMany |
() -> E |
Return value
Result<T, E>