Skip to content

Commit 6afea22

Browse files
committed
Add Zero and One providers
1 parent 5b59648 commit 6afea22

3 files changed

Lines changed: 12 additions & 1 deletion

File tree

README.md

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -76,6 +76,9 @@ It provides an empty instance of a `String`, `Array` or any type that implements
7676
### `True` and `False`
7777
Provide `true` and `false` respectively for `Bool` properties.
7878

79+
### `Zero` and `One`
80+
Provide `0` and `1` respectively for `Int` properties.
81+
7982
### `FirstCase`
8083
It provides the first case of an `enum` type as the default value. The `enum` must implement the `CaseIterable` protocol.
8184

Sources/DefaultCodable/DefaultValueProvider.swift

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,3 +21,11 @@ public enum Empty<A>: DefaultValueProvider where A: Codable, A: Equatable, A: Ra
2121
public enum FirstCase<A>: DefaultValueProvider where A: Codable, A: Equatable, A: CaseIterable {
2222
public static var `default`: A { A.allCases.first! }
2323
}
24+
25+
public enum Zero: DefaultValueProvider {
26+
public static let `default` = 0
27+
}
28+
29+
public enum One: DefaultValueProvider {
30+
public static let `default` = 1
31+
}

Tests/DefaultCodableTests/XCTestManifests.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ import XCTest
22

33
#if !canImport(ObjectiveC)
44
public func allTests() -> [XCTestCaseEntry] {
5-
return [
5+
[
66
testCase(DefaultTests.allTests),
77
]
88
}

0 commit comments

Comments
 (0)