Skip to content

Commit 450e214

Browse files
committed
Simplify replaceNil(with:).
1 parent 1d79f44 commit 450e214

File tree

1 file changed

+1
-3
lines changed

1 file changed

+1
-3
lines changed

Sources/Coding/Decoding.swift

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -23,9 +23,7 @@ public extension Decoding {
2323
}
2424

2525
func replaceNil<T>(with defaultValue: T) -> Decoding<T> where Value == T? {
26-
.init { decoder in
27-
try self.decode(decoder) ?? defaultValue
28-
}
26+
map { $0 ?? defaultValue }
2927
}
3028
}
3129

0 commit comments

Comments
 (0)