@@ -73,7 +73,7 @@ impl<'x> Address<'x> {
73
73
}
74
74
75
75
/// Returns an iterator over the addresses in the list, or the addresses in the groups.
76
- pub fn iter < ' y : ' x > ( & ' y self ) -> Box < dyn Iterator < Item = & Addr < ' x > > + ' x > {
76
+ pub fn iter < ' y : ' x > ( & ' y self ) -> Box < dyn DoubleEndedIterator < Item = & Addr < ' x > > + ' x > {
77
77
match self {
78
78
Address :: List ( list) => Box :: new ( list. iter ( ) ) ,
79
79
Address :: Group ( group) => {
@@ -82,6 +82,24 @@ impl<'x> Address<'x> {
82
82
}
83
83
}
84
84
85
+ /// Returns whether the list contains the given address.
86
+ pub fn contains ( & self , addr : & str ) -> bool {
87
+ match self {
88
+ Address :: List ( list) => list. iter ( ) . any ( |a| {
89
+ a. address
90
+ . as_ref ( )
91
+ . map_or ( false , |a| a. eq_ignore_ascii_case ( addr) )
92
+ } ) ,
93
+ Address :: Group ( group) => group. iter ( ) . any ( |group| {
94
+ group. addresses . iter ( ) . any ( |a| {
95
+ a. address
96
+ . as_ref ( )
97
+ . map_or ( false , |a| a. eq_ignore_ascii_case ( addr) )
98
+ } )
99
+ } ) ,
100
+ }
101
+ }
102
+
85
103
pub fn into_owned ( self ) -> Address < ' static > {
86
104
match self {
87
105
Address :: List ( list) => {
@@ -124,4 +142,12 @@ impl<'x> Addr<'x> {
124
142
address : self . address . map ( |s| s. into_owned ( ) . into ( ) ) ,
125
143
}
126
144
}
145
+
146
+ pub fn name ( & self ) -> Option < & str > {
147
+ self . name . as_deref ( )
148
+ }
149
+
150
+ pub fn address ( & self ) -> Option < & str > {
151
+ self . address . as_deref ( )
152
+ }
127
153
}
0 commit comments