ResultExtensions.swift 524 B

1234567891011121314
  1. import Result
  2. /// Private alias of the free `materialize()` from `Result`.
  3. ///
  4. /// This exists because within a `Signal` or `SignalProducer` operator,
  5. /// `materialize()` refers to the operator with that name.
  6. /// Namespacing as `Result.materialize()` doesn't work either,
  7. /// because it tries to resolve a static member on the _type_
  8. /// `Result`, rather than the free function in the _module_
  9. /// of the same name.
  10. internal func materialize<T>(_ f: () throws -> T) -> Result<T, AnyError> {
  11. return materialize(try f())
  12. }