Use strum macro to implement AmenityType::all

This commit is contained in:
Dustin Carlino 2021-05-06 08:50:29 -07:00
parent 4080d0d130
commit b29a613b42

View File

@ -2,8 +2,8 @@ use std::collections::{BTreeMap, HashSet, VecDeque};
use std::fmt; use std::fmt;
use serde::{Deserialize, Serialize}; use serde::{Deserialize, Serialize};
use strum_macros::Display; use strum::IntoEnumIterator;
use strum_macros::EnumString; use strum_macros::{Display, EnumIter, EnumString};
use abstutil::{ use abstutil::{
deserialize_btreemap, deserialize_usize, serialize_btreemap, serialize_usize, Tags, deserialize_btreemap, deserialize_usize, serialize_btreemap, serialize_usize, Tags,
@ -227,7 +227,7 @@ fn sidewalk_to_bike(sidewalk_pos: Position, map: &Map) -> Option<(Position, Posi
} }
/// Businesses are categorized into one of these types. /// Businesses are categorized into one of these types.
#[derive(Clone, Copy, PartialEq, Eq, PartialOrd, Ord, EnumString, Display)] #[derive(Clone, Copy, PartialEq, Eq, PartialOrd, Ord, EnumString, Display, EnumIter)]
pub enum AmenityType { pub enum AmenityType {
Bank, Bank,
Bar, Bar,
@ -375,38 +375,9 @@ impl AmenityType {
} }
} }
/// All types of amenities, in an arbitrary order. /// All types of amenities, in alphabetical order.
pub fn all() -> Vec<AmenityType> { pub fn all() -> Vec<AmenityType> {
vec![ AmenityType::iter().collect()
AmenityType::Bank,
AmenityType::Bar,
AmenityType::Beauty,
AmenityType::Bike,
AmenityType::Cafe,
AmenityType::CarRepair,
AmenityType::CarShare,
AmenityType::Childcare,
AmenityType::ConvenienceStore,
AmenityType::Culture,
AmenityType::FastFood,
AmenityType::Food,
AmenityType::Exercise,
AmenityType::GreenSpace,
AmenityType::Hotel,
AmenityType::Laundry,
AmenityType::Library,
AmenityType::Medical,
AmenityType::Pet,
AmenityType::Playground,
AmenityType::Pool,
AmenityType::PostOffice,
AmenityType::Religious,
AmenityType::School,
AmenityType::Shopping,
AmenityType::Supermarket,
AmenityType::Tourism,
AmenityType::University,
]
} }
/// Categorize an OSM amenity tag. /// Categorize an OSM amenity tag.