 
     currentState = DeferredState.Executing.rawValue
     dispatch_async(queue) {
-      let result: Result<T>
-      do {    result = .Value(try task()) }
-      catch { result = .Error(error) }
-
+      let result = Result<T> { try task() }
       do {  try self.setResult(result) }
       catch { /* an error here means this `Deferred` was canceled before `task()` was complete. */ }
     }

  private init()
  {
    dispatch_group_enter(group)
  }

  deinit
  {
    if r == nil
    {
      dispatch_group_leave(group)
    }


public class Deferred<T>
{
  private var r: Result<T>
  private let group = dispatch_group_create()

  // Swift does not have a facility to read and write enum values atomically.
