@@ -85,59 +85,9 @@ pub enum LocationConstraint {
85
85
CustomList { list_id : Id } ,
86
86
}
87
87
88
- #[ derive( Debug , Clone ) ]
89
- pub struct ResolvedLocationConstraint ( Vec < GeographicLocationConstraint > ) ;
90
-
91
- impl < ' a > IntoIterator for & ' a ResolvedLocationConstraint {
92
- type Item = & ' a GeographicLocationConstraint ;
93
-
94
- type IntoIter = core:: slice:: Iter < ' a , GeographicLocationConstraint > ;
95
-
96
- fn into_iter ( self ) -> Self :: IntoIter {
97
- self . 0 . iter ( )
98
- }
99
- }
100
-
101
- impl IntoIterator for ResolvedLocationConstraint {
102
- type Item = GeographicLocationConstraint ;
103
-
104
- type IntoIter = std:: vec:: IntoIter < GeographicLocationConstraint > ;
105
-
106
- fn into_iter ( self ) -> Self :: IntoIter {
107
- self . 0 . into_iter ( )
108
- }
109
- }
110
-
111
- impl FromIterator < GeographicLocationConstraint > for ResolvedLocationConstraint {
112
- fn from_iter < T : IntoIterator < Item = GeographicLocationConstraint > > ( iter : T ) -> Self {
113
- Self ( Vec :: from_iter ( iter) )
114
- }
115
- }
116
-
117
- impl ResolvedLocationConstraint {
118
- pub fn from_constraint (
119
- location_constraint : Constraint < LocationConstraint > ,
120
- custom_lists : & CustomListsSettings ,
121
- ) -> Constraint < ResolvedLocationConstraint > {
122
- location_constraint. map ( |location| Self :: from_location_constraint ( location, custom_lists) )
123
- }
124
-
125
- fn from_location_constraint (
126
- location : LocationConstraint ,
127
- custom_lists : & CustomListsSettings ,
128
- ) -> ResolvedLocationConstraint {
129
- match location {
130
- LocationConstraint :: Location ( location) => Self :: from_iter ( std:: iter:: once ( location) ) ,
131
- LocationConstraint :: CustomList { list_id } => custom_lists
132
- . iter ( )
133
- . find ( |list| list. id == list_id)
134
- . map ( |custom_list| Self :: from_iter ( custom_list. locations . clone ( ) ) )
135
- . unwrap_or_else ( || {
136
- log:: warn!( "Resolved non-existent custom list" ) ;
137
- Self :: from_iter ( std:: iter:: empty ( ) )
138
- } ) ,
139
- }
140
- }
88
+ pub struct LocationConstraintFormatter < ' a > {
89
+ pub constraint : & ' a LocationConstraint ,
90
+ pub custom_lists : & ' a CustomListsSettings ,
141
91
}
142
92
143
93
impl From < GeographicLocationConstraint > for LocationConstraint {
@@ -146,39 +96,6 @@ impl From<GeographicLocationConstraint> for LocationConstraint {
146
96
}
147
97
}
148
98
149
- impl Set < Constraint < ResolvedLocationConstraint > > for Constraint < ResolvedLocationConstraint > {
150
- fn is_subset ( & self , other : & Self ) -> bool {
151
- match self {
152
- Constraint :: Any => other. is_any ( ) ,
153
- Constraint :: Only ( locations) => match other {
154
- Constraint :: Any => true ,
155
- Constraint :: Only ( other_locations) => {
156
- for location in locations {
157
- if !other_locations
158
- . into_iter ( )
159
- . any ( |other_location| location. is_subset ( other_location) )
160
- {
161
- return false ;
162
- }
163
- }
164
- true
165
- }
166
- } ,
167
- }
168
- }
169
- }
170
-
171
- impl Match < Relay > for ResolvedLocationConstraint {
172
- fn matches ( & self , relay : & Relay ) -> bool {
173
- self . into_iter ( ) . any ( |location| location. matches ( relay) )
174
- }
175
- }
176
-
177
- pub struct LocationConstraintFormatter < ' a > {
178
- pub constraint : & ' a LocationConstraint ,
179
- pub custom_lists : & ' a CustomListsSettings ,
180
- }
181
-
182
99
impl < ' a > fmt:: Display for LocationConstraintFormatter < ' a > {
183
100
fn fmt ( & self , f : & mut fmt:: Formatter < ' _ > ) -> fmt:: Result {
184
101
match self . constraint {
0 commit comments