@@ -56,6 +56,28 @@ impl BlockPath {
5656 }
5757}
5858
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+
5981impl fmt:: Display for BlockPath {
6082 fn fmt ( & self , f : & mut fmt:: Formatter < ' _ > ) -> fmt:: Result {
6183 f. write_str ( & self . peripheral ) ?;
@@ -95,6 +117,16 @@ impl RegisterPath {
95117 }
96118}
97119
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+
98130impl fmt:: Display for RegisterPath {
99131 fn fmt ( & self , f : & mut fmt:: Formatter < ' _ > ) -> fmt:: Result {
100132 self . block . fmt ( f) ?;
@@ -145,6 +177,16 @@ impl FieldPath {
145177 }
146178}
147179
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+
148190impl fmt:: Display for FieldPath {
149191 fn fmt ( & self , f : & mut fmt:: Formatter < ' _ > ) -> fmt:: Result {
150192 self . register . fmt ( f) ?;
@@ -179,6 +221,16 @@ impl EnumPath {
179221 }
180222}
181223
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+
182234impl fmt:: Display for EnumPath {
183235 fn fmt ( & self , f : & mut fmt:: Formatter < ' _ > ) -> fmt:: Result {
184236 self . field . fmt ( f) ?;
0 commit comments