 }
 
 extension ObjectEncoder.EncodingStrategy where T == Float {
-    public static let throwOnNonConformingFloat = ObjectEncoder.FloatEncodingStrategy.custom {
-        guard let encoder = $1 as? ObjectEncoder.Encoder else {
-            fatalError("unreachable")
-        }
-        guard !$0.isInfinite && !$0.isNaN else {
-            throw _invalidFloatingPointValue($0, at: encoder.codingPath)
-        }
-        encoder.object = NSNumber(value: $0)
+    public static let throwOnNonConformingFloat = ObjectEncoder.FloatEncodingStrategy.custom { float, encoder in
+        guard !float.isInfinite && !float.isNaN else {
+            throw _invalidFloatingPointValue(float, at: encoder.codingPath)
+        }
+        encoder.object = NSNumber(value: float)
     }
 
     public static func convertNonConformingFloatToString(_ positiveInfinity: String,
                                                          _ negativeInfinity: String,
                                                          _ nan: String) -> ObjectEncoder.FloatEncodingStrategy {
-        return .custom {
-            guard let encoder = $1 as? ObjectEncoder.Encoder else {
-                fatalError("unreachable")
-            }
-            if $0 == .infinity {
+        return .custom { float, encoder in
+            if float == .infinity {
                 encoder.object = positiveInfinity
-            } else if $0 == -.infinity {
+            } else if float == -.infinity {
                 encoder.object = negativeInfinity
-            } else if $0.isNaN {
+            } else if float.isNaN {
                 encoder.object = nan
             } else {
-                encoder.object = NSNumber(value: $0)
+                encoder.object = NSNumber(value: float)
             }
         }
     }

    }

    public struct EncodingStrategy<T: Encodable> {
        public typealias Closure = (T, Swift.Encoder) throws -> Void
        public init(identifiers: [ObjectIdentifier], closure: @escaping Closure) {
            self.identifiers = identifiers
            self.closure = closure

    public static let deferredToDate: ObjectEncoder.DateEncodingStrategy? = nil

    /// Encode the `Date` as a UNIX timestamp (as a `Double`).
    public static let secondsSince1970 = ObjectEncoder.DateEncodingStrategy.custom { date, encoder in
        var container = encoder.singleValueContainer()
        try container.encode(date.timeIntervalSince1970)
    }

    /// Encode the `Date` as UNIX millisecond timestamp (as a `Double`).
    public static let millisecondsSince1970 = ObjectEncoder.DateEncodingStrategy.custom { date, encoder in
        var container = encoder.singleValueContainer()
        try container.encode(1000.0 * date.timeIntervalSince1970)
    }

    /// Encode the `Date` as an ISO-8601-formatted string (in RFC 3339 format).
    @available(OSX 10.12, iOS 10.0, watchOS 3.0, tvOS 10.0, *)
    public static let iso8601 = ObjectEncoder.DateEncodingStrategy.custom { date, encoder in
        var container = encoder.singleValueContainer()
        try container.encode(iso8601Formatter.string(from: date))
    }

    /// Encode the `Date` as a string formatted by the given formatter.
    public static func formatted(_ formatter: DateFormatter) -> ObjectEncoder.DateEncodingStrategy {
        return .custom { date, encoder in
            var container = encoder.singleValueContainer()
            try container.encode(formatter.string(from: date))
        }
    }

