From 914ce35259cf18edd1519e64811732687f030408 Mon Sep 17 00:00:00 2001 From: Mingwei Samuel Date: Mon, 4 Nov 2019 17:00:59 -0800 Subject: [PATCH] Change region to be an enum --- README.md | 2 +- src/consts/map.rs | 12 ++--- src/consts/region.rs | 97 ++++++++++++++--------------------- src/endpoints.rs | 78 ++++++++++++++-------------- src/req/regional_requester.rs | 5 +- src/riot_api.rs | 12 ++--- srcgen/endpoints.rs.dt | 2 +- tests/tests_tr.rs | 2 +- 8 files changed, 93 insertions(+), 117 deletions(-) diff --git a/README.md b/README.md index 056a5de..d7c71c7 100644 --- a/README.md +++ b/README.md @@ -23,7 +23,7 @@ Riven currently uses nightly Rust. use riven::RiotApi; use riven::consts::Region; -// Enter tokio async runtime. +// Riven Enter tokio async runtime. let rt = tokio::runtime::Runtime::new().unwrap(); rt.block_on(async { // Create RiotApi instance from key. diff --git a/src/consts/map.rs b/src/consts/map.rs index e89ed15..624c235 100644 --- a/src/consts/map.rs +++ b/src/consts/map.rs @@ -1,9 +1,9 @@ -/////////////////////////////////////////////// -// // -// ! // -// This file is automatically generated! // -// Do not directly edit! // -// // +/////////////////////////////////////////////// +// // +// ! // +// This file is automatically generated! // +// Do not directly edit! // +// // /////////////////////////////////////////////// use serde_repr::{ Serialize_repr, Deserialize_repr }; diff --git a/src/consts/region.rs b/src/consts/region.rs index 0019746..84e586e 100644 --- a/src/consts/region.rs +++ b/src/consts/region.rs @@ -1,64 +1,43 @@ +use strum_macros::{ EnumString, Display, AsRefStr, IntoStaticStr }; + /// A region served by a single game server. /// Each Riot Games API request is directed at a particular region, /// with tournament API requests directed at the AMERICAS "global" region. #[derive(Debug)] #[derive(PartialEq, Eq, Hash, PartialOrd, Ord)] +#[derive(EnumString, Display, AsRefStr, IntoStaticStr)] #[derive(Clone, Copy)] -pub struct Region { - pub key: &'static str, - pub platform: &'static str, -} - -macro_rules! regions { - ( - $( - $key:ident => $plat:expr ; - )* - ) => { - $( - pub const $key: Region = Region { - key: stringify!($key), - platform: $plat, - }; - )* - - #[doc="Get region by name."] - #[doc="# Arguments"] - #[doc="* `name` - Case-insensitive ASCII string to match Regions' `key` or `playform`."] - #[doc="# Returns"] - #[doc="`Some(&Region)` if match found, `None` if no match found."] - #[allow(unreachable_patterns)] - pub fn get(name: &str) -> Option { - match &*name.to_ascii_uppercase() { - $( - stringify!($key) | $plat => Some(Self::$key), - )* - _ => None - } - } - } -} - -impl Region { - // Is this stupid? - regions! { - BR => "BR1"; - EUNE => "EUN1"; - EUW => "EUW1"; - NA => "NA1"; - KR => "KR"; - LAN => "LA1"; - LAS => "LA2"; - OCE => "OC1"; - RU => "RU"; - TR => "TR1"; - JP => "JP1"; - PBE => "PBE1"; - AMERICAS => "AMERICAS"; - EUROPE => "EUROPE"; - ASIA => "ASIA"; - - } +pub enum Region { + #[strum(to_string="BR1", serialize="BR")] + BR, + #[strum(to_string="EUN1", serialize="EUNE")] + EUNE, + #[strum(to_string="EUW1", serialize="EUW")] + EUW, + #[strum(to_string="NA1", serialize="NA")] + NA, + #[strum(to_string="KR", serialize="KR")] + KR, + #[strum(to_string="LA1", serialize="LAN")] + LAN, + #[strum(to_string="LA2", serialize="LAS")] + LAS, + #[strum(to_string="OC1", serialize="OCE")] + OCE, + #[strum(to_string="RU", serialize="RU")] + RU, + #[strum(to_string="TR1", serialize="TR")] + TR, + #[strum(to_string="JP1", serialize="JP")] + JP, + #[strum(to_string="PBE1", serialize="PBE")] + PBE, + #[strum(to_string="AMERICAS", serialize="AMERICAS")] + AMERICAS, + #[strum(to_string="EUROPE", serialize="EUROPE")] + EUROPE, + #[strum(to_string="ASIA", serialize="ASIA")] + ASIA, } #[cfg(test)] @@ -67,13 +46,13 @@ mod tests { #[test] fn test_basic() { - assert_eq!("BR1", Region::BR.platform); + assert_eq!("BR1", Region::BR.to_string()); } #[test] fn test_get() { - assert_eq!(Some(Region::AMERICAS), Region::get("amEricAs")); - assert_eq!(Some(Region::NA), Region::get("na1")); - assert_eq!(None, Region::get("LA")); + assert_eq!(Ok(Region::JP), "JP".parse()); + assert_eq!(Ok(Region::NA), "NA1".parse()); + assert!("LA".parse::().is_err()); } } \ No newline at end of file diff --git a/src/endpoints.rs b/src/endpoints.rs index cfc04a6..17a00bc 100644 --- a/src/endpoints.rs +++ b/src/endpoints.rs @@ -140,7 +140,7 @@ impl<'a> ChampionMasteryV4<'a> { -> impl Future>>> + 'a { let path_string = format!("/lol/champion-mastery/v4/champion-masteries/by-summoner/{}", encrypted_summoner_id); - self.base.get::>("champion-mastery-v4.getAllChampionMasteries", region, path_string, None) + self.base.get::>("champion-mastery-v4.getAllChampionMasteries", region.into(), path_string, None) } /// Get a champion mastery by player ID and champion ID. @@ -154,7 +154,7 @@ impl<'a> ChampionMasteryV4<'a> { -> impl Future>> + 'a { let path_string = format!("/lol/champion-mastery/v4/champion-masteries/by-summoner/{}/by-champion/{}", encrypted_summoner_id, champion_id); - self.base.get::("champion-mastery-v4.getChampionMastery", region, path_string, None) + self.base.get::("champion-mastery-v4.getChampionMastery", region.into(), path_string, None) } /// Get a player's total champion mastery score, which is the sum of individual champion mastery levels. @@ -167,7 +167,7 @@ impl<'a> ChampionMasteryV4<'a> { -> impl Future>> + 'a { let path_string = format!("/lol/champion-mastery/v4/scores/by-summoner/{}", encrypted_summoner_id); - self.base.get::("champion-mastery-v4.getChampionMasteryScore", region, path_string, None) + self.base.get::("champion-mastery-v4.getChampionMasteryScore", region.into(), path_string, None) } } @@ -188,7 +188,7 @@ impl<'a> ChampionV3<'a> { -> impl Future>> + 'a { let path_string = "/lol/platform/v3/champion-rotations".to_owned(); - self.base.get::("champion-v3.getChampionInfo", region, path_string, None) + self.base.get::("champion-v3.getChampionInfo", region.into(), path_string, None) } } @@ -216,7 +216,7 @@ impl<'a> LeagueExpV4<'a> { if let Some(page) = page { query_params.append_pair("page", &*page.to_string()); }; let query_string = query_params.finish(); let path_string = format!("/lol/league-exp/v4/entries/{}/{}/{}", queue, tier, division); - self.base.get::>("league-exp-v4.getLeagueEntries", region, path_string, Some(query_string)) + self.base.get::>("league-exp-v4.getLeagueEntries", region.into(), path_string, Some(query_string)) } } @@ -238,7 +238,7 @@ impl<'a> LeagueV4<'a> { -> impl Future>> + 'a { let path_string = format!("/lol/league/v4/challengerleagues/by-queue/{}", queue); - self.base.get::("league-v4.getChallengerLeague", region, path_string, None) + self.base.get::("league-v4.getChallengerLeague", region.into(), path_string, None) } /// Get league entries in all queues for a given summoner ID. @@ -251,7 +251,7 @@ impl<'a> LeagueV4<'a> { -> impl Future>>> + 'a { let path_string = format!("/lol/league/v4/entries/by-summoner/{}", encrypted_summoner_id); - self.base.get::>("league-v4.getLeagueEntriesForSummoner", region, path_string, None) + self.base.get::>("league-v4.getLeagueEntriesForSummoner", region.into(), path_string, None) } /// Get all the league entries. @@ -270,7 +270,7 @@ impl<'a> LeagueV4<'a> { if let Some(page) = page { query_params.append_pair("page", &*page.to_string()); }; let query_string = query_params.finish(); let path_string = format!("/lol/league/v4/entries/{}/{}/{}", queue, tier, division); - self.base.get::>("league-v4.getLeagueEntries", region, path_string, Some(query_string)) + self.base.get::>("league-v4.getLeagueEntries", region.into(), path_string, Some(query_string)) } /// Get the grandmaster league of a specific queue. @@ -283,7 +283,7 @@ impl<'a> LeagueV4<'a> { -> impl Future>> + 'a { let path_string = format!("/lol/league/v4/grandmasterleagues/by-queue/{}", queue); - self.base.get::("league-v4.getGrandmasterLeague", region, path_string, None) + self.base.get::("league-v4.getGrandmasterLeague", region.into(), path_string, None) } /// Get league with given ID, including inactive entries. @@ -296,7 +296,7 @@ impl<'a> LeagueV4<'a> { -> impl Future>> + 'a { let path_string = format!("/lol/league/v4/leagues/{}", league_id); - self.base.get::("league-v4.getLeagueById", region, path_string, None) + self.base.get::("league-v4.getLeagueById", region.into(), path_string, None) } /// Get the master league for given queue. @@ -309,7 +309,7 @@ impl<'a> LeagueV4<'a> { -> impl Future>> + 'a { let path_string = format!("/lol/league/v4/masterleagues/by-queue/{}", queue); - self.base.get::("league-v4.getMasterLeague", region, path_string, None) + self.base.get::("league-v4.getMasterLeague", region.into(), path_string, None) } } @@ -332,7 +332,7 @@ impl<'a> LolStatusV3<'a> { -> impl Future>> + 'a { let path_string = "/lol/status/v3/shard-data".to_owned(); - self.base.get::("lol-status-v3.getShardData", region, path_string, None) + self.base.get::("lol-status-v3.getShardData", region.into(), path_string, None) } } @@ -354,7 +354,7 @@ impl<'a> MatchV4<'a> { -> impl Future>>> + 'a { let path_string = format!("/lol/match/v4/matches/by-tournament-code/{}/ids", tournament_code); - self.base.get::>("match-v4.getMatchIdsByTournamentCode", region, path_string, None) + self.base.get::>("match-v4.getMatchIdsByTournamentCode", region.into(), path_string, None) } /// Get match by match ID. @@ -367,7 +367,7 @@ impl<'a> MatchV4<'a> { -> impl Future>> + 'a { let path_string = format!("/lol/match/v4/matches/{}", match_id); - self.base.get::("match-v4.getMatch", region, path_string, None) + self.base.get::("match-v4.getMatch", region.into(), path_string, None) } /// Get match by match ID and tournament code. @@ -381,7 +381,7 @@ impl<'a> MatchV4<'a> { -> impl Future>> + 'a { let path_string = format!("/lol/match/v4/matches/{}/by-tournament-code/{}", match_id, tournament_code); - self.base.get::("match-v4.getMatchByTournamentCode", region, path_string, None) + self.base.get::("match-v4.getMatchByTournamentCode", region.into(), path_string, None) } /// Get matchlist for games played on given account ID and platform ID and filtered using given filter parameters, if any. @@ -416,7 +416,7 @@ impl<'a> MatchV4<'a> { if let Some(season) = season { query_params.extend_pairs(season.iter().map(|w| ("season", Into::::into(*w).to_string()))); }; let query_string = query_params.finish(); let path_string = format!("/lol/match/v4/matchlists/by-account/{}", encrypted_account_id); - self.base.get::("match-v4.getMatchlist", region, path_string, Some(query_string)) + self.base.get::("match-v4.getMatchlist", region.into(), path_string, Some(query_string)) } /// Get match timeline by match ID. @@ -431,7 +431,7 @@ impl<'a> MatchV4<'a> { -> impl Future>> + 'a { let path_string = format!("/lol/match/v4/timelines/by-match/{}", match_id); - self.base.get::("match-v4.getMatchTimeline", region, path_string, None) + self.base.get::("match-v4.getMatchTimeline", region.into(), path_string, None) } } @@ -453,7 +453,7 @@ impl<'a> SpectatorV4<'a> { -> impl Future>> + 'a { let path_string = format!("/lol/spectator/v4/active-games/by-summoner/{}", encrypted_summoner_id); - self.base.get::("spectator-v4.getCurrentGameInfoBySummoner", region, path_string, None) + self.base.get::("spectator-v4.getCurrentGameInfoBySummoner", region.into(), path_string, None) } /// Get list of featured games. @@ -465,7 +465,7 @@ impl<'a> SpectatorV4<'a> { -> impl Future>> + 'a { let path_string = "/lol/spectator/v4/featured-games".to_owned(); - self.base.get::("spectator-v4.getFeaturedGames", region, path_string, None) + self.base.get::("spectator-v4.getFeaturedGames", region.into(), path_string, None) } } @@ -487,7 +487,7 @@ impl<'a> SummonerV4<'a> { -> impl Future>> + 'a { let path_string = format!("/lol/summoner/v4/summoners/by-account/{}", encrypted_account_id); - self.base.get::("summoner-v4.getByAccountId", region, path_string, None) + self.base.get::("summoner-v4.getByAccountId", region.into(), path_string, None) } /// Get a summoner by summoner name. @@ -500,7 +500,7 @@ impl<'a> SummonerV4<'a> { -> impl Future>> + 'a { let path_string = format!("/lol/summoner/v4/summoners/by-name/{}", summoner_name); - self.base.get::("summoner-v4.getBySummonerName", region, path_string, None) + self.base.get::("summoner-v4.getBySummonerName", region.into(), path_string, None) } /// Get a summoner by PUUID. @@ -513,7 +513,7 @@ impl<'a> SummonerV4<'a> { -> impl Future>> + 'a { let path_string = format!("/lol/summoner/v4/summoners/by-puuid/{}", encrypted_puuid); - self.base.get::("summoner-v4.getByPUUID", region, path_string, None) + self.base.get::("summoner-v4.getByPUUID", region.into(), path_string, None) } /// Get a summoner by summoner ID. @@ -526,7 +526,7 @@ impl<'a> SummonerV4<'a> { -> impl Future>> + 'a { let path_string = format!("/lol/summoner/v4/summoners/{}", encrypted_summoner_id); - self.base.get::("summoner-v4.getBySummonerId", region, path_string, None) + self.base.get::("summoner-v4.getBySummonerId", region.into(), path_string, None) } } @@ -547,7 +547,7 @@ impl<'a> TftLeagueV1<'a> { -> impl Future>> + 'a { let path_string = "/tft/league/v1/challenger".to_owned(); - self.base.get::("tft-league-v1.getChallengerLeague", region, path_string, None) + self.base.get::("tft-league-v1.getChallengerLeague", region.into(), path_string, None) } /// Get league entries for a given summoner ID. @@ -560,7 +560,7 @@ impl<'a> TftLeagueV1<'a> { -> impl Future>>> + 'a { let path_string = format!("/tft/league/v1/entries/by-summoner/{}", encrypted_summoner_id); - self.base.get::>("tft-league-v1.getLeagueEntriesForSummoner", region, path_string, None) + self.base.get::>("tft-league-v1.getLeagueEntriesForSummoner", region.into(), path_string, None) } /// Get all the league entries. @@ -578,7 +578,7 @@ impl<'a> TftLeagueV1<'a> { if let Some(page) = page { query_params.append_pair("page", &*page.to_string()); }; let query_string = query_params.finish(); let path_string = format!("/tft/league/v1/entries/{}/{}", tier, division); - self.base.get::>("tft-league-v1.getLeagueEntries", region, path_string, Some(query_string)) + self.base.get::>("tft-league-v1.getLeagueEntries", region.into(), path_string, Some(query_string)) } /// Get the grandmaster league. @@ -590,7 +590,7 @@ impl<'a> TftLeagueV1<'a> { -> impl Future>> + 'a { let path_string = "/tft/league/v1/grandmaster".to_owned(); - self.base.get::("tft-league-v1.getGrandmasterLeague", region, path_string, None) + self.base.get::("tft-league-v1.getGrandmasterLeague", region.into(), path_string, None) } /// Get league with given ID, including inactive entries. @@ -603,7 +603,7 @@ impl<'a> TftLeagueV1<'a> { -> impl Future>> + 'a { let path_string = format!("/tft/league/v1/leagues/{}", league_id); - self.base.get::("tft-league-v1.getLeagueById", region, path_string, None) + self.base.get::("tft-league-v1.getLeagueById", region.into(), path_string, None) } /// Get the master league. @@ -615,7 +615,7 @@ impl<'a> TftLeagueV1<'a> { -> impl Future>> + 'a { let path_string = "/tft/league/v1/master".to_owned(); - self.base.get::("tft-league-v1.getMasterLeague", region, path_string, None) + self.base.get::("tft-league-v1.getMasterLeague", region.into(), path_string, None) } } @@ -637,7 +637,7 @@ impl<'a> TftMatchV1<'a> { -> impl Future>>> + 'a { let path_string = format!("/tft/match/v1/matches/by-puuid/{}/ids", encrypted_puuid); - self.base.get::>("tft-match-v1.getMatchIdsByPUUID", region, path_string, None) + self.base.get::>("tft-match-v1.getMatchIdsByPUUID", region.into(), path_string, None) } /// Get a match by match id. @@ -650,7 +650,7 @@ impl<'a> TftMatchV1<'a> { -> impl Future>> + 'a { let path_string = format!("/tft/match/v1/matches/{}", match_id); - self.base.get::("tft-match-v1.getMatch", region, path_string, None) + self.base.get::("tft-match-v1.getMatch", region.into(), path_string, None) } } @@ -672,7 +672,7 @@ impl<'a> TftSummonerV1<'a> { -> impl Future>> + 'a { let path_string = format!("/tft/summoner/v1/summoners/by-account/{}", encrypted_account_id); - self.base.get::("tft-summoner-v1.getByAccountId", region, path_string, None) + self.base.get::("tft-summoner-v1.getByAccountId", region.into(), path_string, None) } /// Get a summoner by summoner name. @@ -685,7 +685,7 @@ impl<'a> TftSummonerV1<'a> { -> impl Future>> + 'a { let path_string = format!("/tft/summoner/v1/summoners/by-name/{}", summoner_name); - self.base.get::("tft-summoner-v1.getBySummonerName", region, path_string, None) + self.base.get::("tft-summoner-v1.getBySummonerName", region.into(), path_string, None) } /// Get a summoner by PUUID. @@ -698,7 +698,7 @@ impl<'a> TftSummonerV1<'a> { -> impl Future>> + 'a { let path_string = format!("/tft/summoner/v1/summoners/by-puuid/{}", encrypted_puuid); - self.base.get::("tft-summoner-v1.getByPUUID", region, path_string, None) + self.base.get::("tft-summoner-v1.getByPUUID", region.into(), path_string, None) } /// Get a summoner by summoner ID. @@ -711,7 +711,7 @@ impl<'a> TftSummonerV1<'a> { -> impl Future>> + 'a { let path_string = format!("/tft/summoner/v1/summoners/{}", encrypted_summoner_id); - self.base.get::("tft-summoner-v1.getBySummonerId", region, path_string, None) + self.base.get::("tft-summoner-v1.getBySummonerId", region.into(), path_string, None) } } @@ -733,7 +733,7 @@ impl<'a> ThirdPartyCodeV4<'a> { -> impl Future>> + 'a { let path_string = format!("/lol/platform/v4/third-party-code/by-summoner/{}", encrypted_summoner_id); - self.base.get::("third-party-code-v4.getThirdPartyCodeBySummonerId", region, path_string, None) + self.base.get::("third-party-code-v4.getThirdPartyCodeBySummonerId", region.into(), path_string, None) } } @@ -755,7 +755,7 @@ impl<'a> TournamentStubV4<'a> { -> impl Future>> + 'a { let path_string = format!("/lol/tournament-stub/v4/lobby-events/by-code/{}", tournament_code); - self.base.get::("tournament-stub-v4.getLobbyEventsByCode", region, path_string, None) + self.base.get::("tournament-stub-v4.getLobbyEventsByCode", region.into(), path_string, None) } } @@ -777,7 +777,7 @@ impl<'a> TournamentV4<'a> { -> impl Future>> + 'a { let path_string = format!("/lol/tournament/v4/codes/{}", tournament_code); - self.base.get::("tournament-v4.getTournamentCode", region, path_string, None) + self.base.get::("tournament-v4.getTournamentCode", region.into(), path_string, None) } /// Gets a list of lobby events by tournament code. @@ -790,7 +790,7 @@ impl<'a> TournamentV4<'a> { -> impl Future>> + 'a { let path_string = format!("/lol/tournament/v4/lobby-events/by-code/{}", tournament_code); - self.base.get::("tournament-v4.getLobbyEventsByCode", region, path_string, None) + self.base.get::("tournament-v4.getLobbyEventsByCode", region.into(), path_string, None) } } diff --git a/src/req/regional_requester.rs b/src/req/regional_requester.rs index 07df06c..b8e5f95 100644 --- a/src/req/regional_requester.rs +++ b/src/req/regional_requester.rs @@ -8,7 +8,6 @@ use tokio::timer::delay_for; use crate::Result; use crate::RiotApiError; use crate::RiotApiConfig; -use crate::consts::Region; use crate::util::InsertOnlyCHashMap; use super::RateLimit; @@ -38,7 +37,7 @@ impl RegionalRequester { pub fn get<'a, T: serde::de::DeserializeOwned>(self: Arc, config: &'a RiotApiConfig, client: &'a Client, - method_id: &'static str, region: Region, path: String, query: Option) + method_id: &'static str, region_platform: &'a str, path: String, query: Option) -> impl Future>> + 'a { async move { @@ -55,7 +54,7 @@ impl RegionalRequester { } // Send request. - let url_base = format!("https://{}.api.riotgames.com", region.platform); + let url_base = format!("https://{}.api.riotgames.com", region_platform); let mut url = Url::parse(&*url_base) .unwrap_or_else(|_| panic!("Failed to parse url_base: \"{}\".", url_base)); url.set_path(&*path); diff --git a/src/riot_api.rs b/src/riot_api.rs index 34733ab..4c73c0b 100644 --- a/src/riot_api.rs +++ b/src/riot_api.rs @@ -5,7 +5,6 @@ use reqwest::Client; use crate::Result; use crate::RiotApiConfig; -use crate::consts::Region; use crate::req::RegionalRequester; use crate::util::InsertOnlyCHashMap; @@ -27,7 +26,7 @@ pub struct RiotApi { client: Client, /// Per-region requesters. - regional_requesters: InsertOnlyCHashMap, + regional_requesters: InsertOnlyCHashMap<&'static str, RegionalRequester>, } impl RiotApi { @@ -46,15 +45,14 @@ impl RiotApi { } pub fn get<'a, T: serde::de::DeserializeOwned + 'a>(&'a self, - method_id: &'static str, region: Region, path: String, query: Option) + method_id: &'static str, region_platform: &'static str, path: String, query: Option) -> impl Future>> + 'a { - // TODO: max concurrent requests? Or can configure client? self.regional_requesters - .get_or_insert_with(region, || { - log::debug!("Creating requester for region {}.", region.platform); + .get_or_insert_with(region_platform, || { + log::debug!("Creating requester for region platform {}.", region_platform); RegionalRequester::new() }) - .get(&self.config, &self.client, method_id, region, path, query) + .get(&self.config, &self.client, method_id, region_platform, path, query) } } diff --git a/srcgen/endpoints.rs.dt b/srcgen/endpoints.rs.dt index 381bdd4..d08b58e 100644 --- a/srcgen/endpoints.rs.dt +++ b/srcgen/endpoints.rs.dt @@ -146,7 +146,7 @@ impl<'a> {{= endpoint }}<'a> { let query_string = query_params.finish(); {{?}} let path_string = {{= routeArgument }}; - self.base.get::<{{= returnType }}>("{{= operationId }}", region, path_string, {{= queryParams.length ? 'Some(query_string)' : 'None' }}) + self.base.get::<{{= returnType }}>("{{= operationId }}", region.into(), path_string, {{= queryParams.length ? 'Some(query_string)' : 'None' }}) } {{ diff --git a/tests/tests_tr.rs b/tests/tests_tr.rs index 59a4b98..27841cb 100644 --- a/tests/tests_tr.rs +++ b/tests/tests_tr.rs @@ -20,7 +20,7 @@ async_tests!{ // let p = future_start(p); let ll = p.await.map_err(|e| e.to_string())?.ok_or("Failed to get challenger league".to_owned())?; - println!("{} Challenger {} entries.", REGION.key, ll.entries.len()); + println!("{:?} Challenger {} entries.", REGION, ll.entries.len()); let sl = ll.entries[..50].iter() .map(|entry| RIOT_API.summoner_v4().get_by_summoner_id(REGION, &entry.summoner_id))