@@ -234,12 +234,14 @@ nonisolated struct CSVKeyedEncodingContainer<Key: CodingKey>: KeyedEncodingConta
234234 ) -> KeyedEncodingContainer < NestedKey > {
235235 switch configuration. nestedTypeEncodingStrategy {
236236 case . error:
237- return KeyedEncodingContainer ( CSVPoisonKeyedEncodingContainer < NestedKey > (
238- error: CSVEncodingError . unsupportedType (
239- " Nested containers are not supported in CSV. Configure nestedTypeEncodingStrategy to enable. "
240- ) ,
241- codingPath: codingPath + [ key] ,
242- ) )
237+ return KeyedEncodingContainer (
238+ CSVPoisonKeyedEncodingContainer < NestedKey > (
239+ error: CSVEncodingError . unsupportedType (
240+ " Nested containers are not supported in CSV. Configure nestedTypeEncodingStrategy to enable. "
241+ ) ,
242+ codingPath: codingPath + [ key] ,
243+ )
244+ )
243245
244246 case . flatten( let separator) :
245247 let nestedPrefix = prefixedKey ( key) + separator
@@ -253,12 +255,14 @@ nonisolated struct CSVKeyedEncodingContainer<Key: CodingKey>: KeyedEncodingConta
253255
254256 case . codable,
255257 . json:
256- return KeyedEncodingContainer ( CSVPoisonKeyedEncodingContainer < NestedKey > (
257- error: CSVEncodingError . unsupportedType (
258- " JSON/Codable nested encoding requires using encode(_:forKey:) with the nested value directly "
259- ) ,
260- codingPath: codingPath + [ key] ,
261- ) )
258+ return KeyedEncodingContainer (
259+ CSVPoisonKeyedEncodingContainer < NestedKey > (
260+ error: CSVEncodingError . unsupportedType (
261+ " JSON/Codable nested encoding requires using encode(_:forKey:) with the nested value directly "
262+ ) ,
263+ codingPath: codingPath + [ key] ,
264+ )
265+ )
262266 }
263267 }
264268
@@ -299,12 +303,16 @@ nonisolated struct CSVKeyedEncodingContainer<Key: CodingKey>: KeyedEncodingConta
299303 }
300304
301305 mutating func encodeIfPresent( _ value: Double ? , forKey key: Key ) throws {
302- let formatted = try value. map { try CSVValueFormatter . formatNumber ( $0, strategy: configuration. numberEncodingStrategy) }
306+ let formatted = try value. map {
307+ try CSVValueFormatter . formatNumber ( $0, strategy: configuration. numberEncodingStrategy)
308+ }
303309 storage. setValue ( formatted ?? " " , forKey: prefixedKey ( key) )
304310 }
305311
306312 mutating func encodeIfPresent( _ value: Float ? , forKey key: Key ) throws {
307- let formatted = try value. map { try CSVValueFormatter . formatNumber ( Double ( $0) , strategy: configuration. numberEncodingStrategy) }
313+ let formatted = try value. map {
314+ try CSVValueFormatter . formatNumber ( Double ( $0) , strategy: configuration. numberEncodingStrategy)
315+ }
308316 storage. setValue ( formatted ?? " " , forKey: prefixedKey ( key) )
309317 }
310318
0 commit comments