@@ -240,6 +240,11 @@ impl Region {
240240 DETAILS [ * self ]
241241 }
242242
243+ /// Iterate over all known [regions][Region].
244+ pub fn all ( ) -> impl Iterator < Item = ( Region , RegionDetails < ' static > ) > {
245+ DETAILS . iter ( ) . map ( |( r, d) | ( r, * d) )
246+ }
247+
243248 fn key ( & self ) -> RegionKey < ' _ > {
244249 ( self . city . geo . x ( ) , self . city . geo . y ( ) , & self . code )
245250 }
@@ -330,7 +335,7 @@ impl FromStr for Region {
330335/// assert_eq!(city.name, "Atlanta");
331336/// assert_eq!(name, "Atlanta, Georgia (US)");
332337/// ```
333- #[ derive( Copy , Clone , Debug ) ]
338+ #[ derive( Copy , Clone , Debug , PartialEq , Eq ) ]
334339#[ cfg_attr( feature = "serde" , derive( serde:: Deserialize , serde:: Serialize ) ) ]
335340pub struct RegionDetails < ' l > {
336341 pub code : & ' l str ,
@@ -359,7 +364,7 @@ impl RegionDetails<'static> {
359364}
360365
361366/// Describes a city where a Fly.io [region][Region] is hosted.
362- #[ derive( Copy , Clone , Debug ) ]
367+ #[ derive( Copy , Clone , Debug , PartialEq , Eq ) ]
363368#[ cfg_attr( feature = "serde" , derive( serde:: Deserialize , serde:: Serialize ) ) ]
364369pub struct City < ' l > {
365370 pub name : & ' l str ,
@@ -597,4 +602,10 @@ mod test {
597602 regions
598603 ) ;
599604 }
605+
606+ #[ test]
607+ fn all ( ) {
608+ assert ! ( Region :: all( ) . count( ) >= 30 ) ;
609+ assert ! ( Region :: all( ) . all( |( r, d) | r. details( ) == d) ) ;
610+ }
600611}
0 commit comments