@@ -56,6 +56,28 @@ impl BlockPath {
56
56
}
57
57
}
58
58
59
+ impl PartialEq < str > for BlockPath {
60
+ fn eq ( & self , other : & str ) -> bool {
61
+ if other. split ( '.' ) . count ( ) != self . path . len ( ) + 1 {
62
+ return false ;
63
+ }
64
+ let mut parts = other. split ( '.' ) ;
65
+ if let Some ( part1) = parts. next ( ) {
66
+ if self . peripheral != part1 {
67
+ return false ;
68
+ }
69
+ for p in parts. zip ( self . path . iter ( ) ) {
70
+ if p. 0 != p. 1 {
71
+ return false ;
72
+ }
73
+ }
74
+ true
75
+ } else {
76
+ false
77
+ }
78
+ }
79
+ }
80
+
59
81
impl fmt:: Display for BlockPath {
60
82
fn fmt ( & self , f : & mut fmt:: Formatter < ' _ > ) -> fmt:: Result {
61
83
f. write_str ( & self . peripheral ) ?;
@@ -95,6 +117,16 @@ impl RegisterPath {
95
117
}
96
118
}
97
119
120
+ impl PartialEq < str > for RegisterPath {
121
+ fn eq ( & self , other : & str ) -> bool {
122
+ if let Some ( ( block, reg) ) = other. rsplit_once ( '.' ) {
123
+ self . name == reg && & self . block == block
124
+ } else {
125
+ false
126
+ }
127
+ }
128
+ }
129
+
98
130
impl fmt:: Display for RegisterPath {
99
131
fn fmt ( & self , f : & mut fmt:: Formatter < ' _ > ) -> fmt:: Result {
100
132
self . block . fmt ( f) ?;
@@ -145,6 +177,16 @@ impl FieldPath {
145
177
}
146
178
}
147
179
180
+ impl PartialEq < str > for FieldPath {
181
+ fn eq ( & self , other : & str ) -> bool {
182
+ if let Some ( ( reg, field) ) = other. rsplit_once ( '.' ) {
183
+ self . name == field && & self . register == reg
184
+ } else {
185
+ false
186
+ }
187
+ }
188
+ }
189
+
148
190
impl fmt:: Display for FieldPath {
149
191
fn fmt ( & self , f : & mut fmt:: Formatter < ' _ > ) -> fmt:: Result {
150
192
self . register . fmt ( f) ?;
@@ -179,6 +221,16 @@ impl EnumPath {
179
221
}
180
222
}
181
223
224
+ impl PartialEq < str > for EnumPath {
225
+ fn eq ( & self , other : & str ) -> bool {
226
+ if let Some ( ( field, evs) ) = other. rsplit_once ( '.' ) {
227
+ self . name == evs && & self . field == field
228
+ } else {
229
+ false
230
+ }
231
+ }
232
+ }
233
+
182
234
impl fmt:: Display for EnumPath {
183
235
fn fmt ( & self , f : & mut fmt:: Formatter < ' _ > ) -> fmt:: Result {
184
236
self . field . fmt ( f) ?;
0 commit comments