Skip to content

Commit 539cfad

Browse files
committed
Moves protocol conformance noise into their own extensions.
1 parent 2bdaa07 commit 539cfad

File tree

3 files changed

+52
-34
lines changed

3 files changed

+52
-34
lines changed

Sources/DataSources/AnimatableSectionModel.swift

Lines changed: 22 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -8,35 +8,42 @@
88

99
import Foundation
1010

11-
public struct AnimatableSectionModel<Section: IdentifiableType, ItemType: IdentifiableType & Equatable>
12-
: AnimatableSectionModelType
13-
, CustomStringConvertible {
14-
public typealias Item = ItemType
15-
public typealias Identity = Section.Identity
16-
11+
public struct AnimatableSectionModel<Section: IdentifiableType, ItemType: IdentifiableType & Equatable> {
1712
public var model: Section
18-
1913
public var items: [Item]
2014

21-
public var identity: Section.Identity {
22-
return model.identity
23-
}
24-
2515
public init(model: Section, items: [ItemType]) {
2616
self.model = model
2717
self.items = items
2818
}
2919

20+
}
21+
22+
extension AnimatableSectionModel
23+
: AnimatableSectionModelType {
24+
public typealias Item = ItemType
25+
public typealias Identity = Section.Identity
26+
27+
public var identity: Section.Identity {
28+
return model.identity
29+
}
30+
3031
public init(original: AnimatableSectionModel, items: [Item]) {
3132
self.model = original.model
3233
self.items = items
3334
}
3435

35-
public var description: String {
36-
return "HashableSectionModel(model: \"\(self.model)\", items: \(items))"
37-
}
38-
3936
public var hashValue: Int {
4037
return self.model.identity.hashValue
4138
}
4239
}
40+
41+
42+
extension AnimatableSectionModel
43+
: CustomStringConvertible {
44+
45+
public var description: String {
46+
return "HashableSectionModel(model: \"\(self.model)\", items: \(items))"
47+
}
48+
49+
}

Sources/DataSources/IdentifiableValue.swift

Lines changed: 14 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -8,18 +8,24 @@
88

99
import Foundation
1010

11-
public struct IdentifiableValue<Value: Hashable>
12-
: IdentifiableType
13-
, Equatable
14-
, CustomStringConvertible
15-
, CustomDebugStringConvertible {
16-
public typealias Identity = Value
17-
11+
public struct IdentifiableValue<Value: Hashable> {
1812
public let value: Value
13+
}
14+
15+
extension IdentifiableValue
16+
: IdentifiableType {
17+
18+
public typealias Identity = Value
1919

2020
public var identity : Identity {
2121
return value
2222
}
23+
}
24+
25+
extension IdentifiableValue
26+
: Equatable
27+
, CustomStringConvertible
28+
, CustomDebugStringConvertible {
2329

2430
public var description: String {
2531
return "\(value)"
@@ -32,4 +38,4 @@ public struct IdentifiableValue<Value: Hashable>
3238

3339
public func == <V: Hashable>(lhs: IdentifiableValue<V>, rhs: IdentifiableValue<V>) -> Bool {
3440
return lhs.value == rhs.value
35-
}
41+
}

Sources/DataSources/SectionModel.swift

Lines changed: 16 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -8,23 +8,28 @@
88

99
import Foundation
1010

11-
public struct SectionModel<Section, ItemType>
12-
: SectionModelType
13-
, CustomStringConvertible {
14-
public typealias Identity = Section
15-
public typealias Item = ItemType
11+
public struct SectionModel<Section, ItemType> {
1612
public var model: Section
17-
18-
public var identity: Section {
19-
return model
20-
}
21-
2213
public var items: [Item]
2314

2415
public init(model: Section, items: [Item]) {
2516
self.model = model
2617
self.items = items
2718
}
19+
}
20+
21+
extension SectionModel
22+
: SectionModelType {
23+
public typealias Identity = Section
24+
public typealias Item = ItemType
25+
26+
public var identity: Section {
27+
return model
28+
}
29+
}
30+
31+
extension SectionModel
32+
: CustomStringConvertible {
2833

2934
public var description: String {
3035
return "\(self.model) > \(items)"
@@ -36,4 +41,4 @@ extension SectionModel {
3641
self.model = original.model
3742
self.items = items
3843
}
39-
}
44+
}

0 commit comments

Comments
 (0)