8
8
9
9
public protocol EventType : Hashable { }
10
10
11
- // MARK: _Event (internal)
12
-
13
- internal enum _Event < E: EventType > : Hashable
14
- {
15
- case Some( E )
16
- case Any // represents any `Some(E)` events but not `.None`
17
- case None // default internal value for `addRoute()` without event
18
-
19
- internal var hashValue : Int
20
- {
21
- switch self {
22
- case . Some( let x) : return x. hashValue
23
- case . Any: return - 4611686018427387904
24
- case . None: return - 4611686018427387905
25
- }
26
- }
27
-
28
- internal var value : E ?
29
- {
30
- switch self {
31
- case . Some( let x) : return x
32
- default : return nil
33
- }
34
- }
35
- }
36
-
37
- internal func == < E: Hashable > ( lhs: _Event < E > , rhs: _Event < E > ) -> Bool
38
- {
39
- return lhs. hashValue == rhs. hashValue
40
- }
41
-
42
- internal func == < E: Hashable > ( lhs: _Event < E > , rhs: E ) -> Bool
43
- {
44
- return lhs. hashValue == rhs. hashValue
45
- }
46
-
47
- internal func == < E: Hashable > ( lhs: E , rhs: _Event < E > ) -> Bool
48
- {
49
- return lhs. hashValue == rhs. hashValue
50
- }
51
-
52
11
// MARK: Event (public)
53
12
54
13
/// `EventType` wrapper for handling`.Any` event.
@@ -100,4 +59,46 @@ public enum NoEvent: EventType
100
59
public func == ( lhs: NoEvent , rhs: NoEvent ) -> Bool
101
60
{
102
61
return true
103
- }
62
+ }
63
+
64
+ // MARK: _Event (internal)
65
+
66
+ /// Internal `EventType` wrapper for `Event` + `Optional` + `Hashable`.
67
+ internal enum _Event < E: EventType > : Hashable
68
+ {
69
+ case Some( E )
70
+ case Any // represents any `Some(E)` events but not `.None`, for `addRouteEvent(.Any)`
71
+ case None // default internal value for `addRoute()` without event
72
+
73
+ internal var hashValue : Int
74
+ {
75
+ switch self {
76
+ case . Some( let x) : return x. hashValue
77
+ case . Any: return - 4611686018427387904
78
+ case . None: return - 4611686018427387905
79
+ }
80
+ }
81
+
82
+ internal var value : E ?
83
+ {
84
+ switch self {
85
+ case . Some( let x) : return x
86
+ default : return nil
87
+ }
88
+ }
89
+ }
90
+
91
+ internal func == < E: Hashable > ( lhs: _Event < E > , rhs: _Event < E > ) -> Bool
92
+ {
93
+ return lhs. hashValue == rhs. hashValue
94
+ }
95
+
96
+ internal func == < E: Hashable > ( lhs: _Event < E > , rhs: E ) -> Bool
97
+ {
98
+ return lhs. hashValue == rhs. hashValue
99
+ }
100
+
101
+ internal func == < E: Hashable > ( lhs: E , rhs: _Event < E > ) -> Bool
102
+ {
103
+ return lhs. hashValue == rhs. hashValue
104
+ }
0 commit comments