diff --git a/riven/examples/proxy/main.rs b/riven/examples/proxy/main.rs index 5a5e4fc..48882fa 100644 --- a/riven/examples/proxy/main.rs +++ b/riven/examples/proxy/main.rs @@ -4,14 +4,12 @@ use std::convert::Infallible; use http::{Method, Request, Response, StatusCode}; use hyper::header::HeaderValue; -use hyper::http; use hyper::service::{make_service_fn, service_fn}; -use hyper::{Body, Server}; +use hyper::{http, Body, Server}; use lazy_static::lazy_static; -use tracing as log; - use riven::consts::Route; use riven::{RiotApi, RiotApiConfig}; +use tracing as log; lazy_static! { /// Create lazy static RiotApi instance. diff --git a/riven/src/config.rs b/riven/src/config.rs index 4627d4c..258f278 100644 --- a/riven/src/config.rs +++ b/riven/src/config.rs @@ -5,8 +5,6 @@ use reqwest::header::{HeaderMap, HeaderValue}; use reqwest::ClientBuilder; /// Configuration for instantiating RiotApi. -/// -/// #[derive(Debug)] pub struct RiotApiConfig { pub(crate) base_url: String, diff --git a/riven/src/consts/macros.rs b/riven/src/consts/macros.rs index 26fe1a6..14028d9 100644 --- a/riven/src/consts/macros.rs +++ b/riven/src/consts/macros.rs @@ -7,7 +7,7 @@ /// /// Also implements `AsRef`, `Display`, and `From<&str>`. macro_rules! serde_strum_unknown { - ( $name:ident ) => { + ($name:ident) => { impl AsRef for $name { fn as_ref(&self) -> &str { match self { diff --git a/riven/src/consts/mod.rs b/riven/src/consts/mod.rs index 613d664..986e6bc 100644 --- a/riven/src/consts/mod.rs +++ b/riven/src/consts/mod.rs @@ -47,11 +47,8 @@ pub use route_ext::*; #[rustfmt::skip] mod season; pub use season::*; - /// Trait allowing iteration of enum types, implemented by several enums in this module. /// Re-exported from strum. -/// -/// pub use strum::IntoEnumIterator; mod team; diff --git a/riven/src/req/mod.rs b/riven/src/req/mod.rs index d07b3df..3991417 100644 --- a/riven/src/req/mod.rs +++ b/riven/src/req/mod.rs @@ -4,9 +4,9 @@ mod rate_limit; pub use rate_limit::*; mod rate_limit_type; -pub use rate_limit_type::*; +use std::time::Instant; -use std::time::Instant; // Hack for token_bucket_test.rs. +pub use rate_limit_type::*; // Hack for token_bucket_test.rs. mod token_bucket; pub use token_bucket::*; diff --git a/riven/src/req/rate_limit.rs b/riven/src/req/rate_limit.rs index 7b04824..f8e51cf 100644 --- a/riven/src/req/rate_limit.rs +++ b/riven/src/req/rate_limit.rs @@ -1,16 +1,14 @@ use std::cmp; use std::time::{Duration, Instant}; -#[cfg(feature = "tracing")] -use tracing as log; - use parking_lot::{RwLock, RwLockUpgradableReadGuard}; use reqwest::{Response, StatusCode}; use scan_fmt::scan_fmt; use tokio::sync::Notify; +#[cfg(feature = "tracing")] +use tracing as log; -use super::RateLimitType; -use super::{TokenBucket, VectorTokenBucket}; +use super::{RateLimitType, TokenBucket, VectorTokenBucket}; use crate::RiotApiConfig; pub struct RateLimit { diff --git a/riven/src/req/regional_requester.rs b/riven/src/req/regional_requester.rs index 08a79d7..7dab098 100644 --- a/riven/src/req/regional_requester.rs +++ b/riven/src/req/regional_requester.rs @@ -1,21 +1,15 @@ use std::future::Future; use std::sync::Arc; +use reqwest::{RequestBuilder, StatusCode}; #[cfg(feature = "tracing")] use tracing as log; #[cfg(feature = "tracing")] use tracing::Instrument; -use reqwest::{RequestBuilder, StatusCode}; - +use super::{RateLimit, RateLimitType}; use crate::util::InsertOnlyCHashMap; -use crate::ResponseInfo; -use crate::Result; -use crate::RiotApiConfig; -use crate::RiotApiError; - -use super::RateLimit; -use super::RateLimitType; +use crate::{ResponseInfo, Result, RiotApiConfig, RiotApiError}; pub struct RegionalRequester { /// The app rate limit. diff --git a/riven/src/req/token_bucket.test.rs b/riven/src/req/token_bucket.test.rs index 65aaa32..56d335d 100644 --- a/riven/src/req/token_bucket.test.rs +++ b/riven/src/req/token_bucket.test.rs @@ -7,9 +7,10 @@ mod token_bucket { include!("token_bucket.rs"); mod tests { - use super::*; use lazy_static::lazy_static; + use super::*; + lazy_static! { pub static ref ZERO: Duration = Duration::new(0, 0); } diff --git a/riven/src/riot_api.rs b/riven/src/riot_api.rs index 3d30ede..f09a600 100644 --- a/riven/src/riot_api.rs +++ b/riven/src/riot_api.rs @@ -1,17 +1,13 @@ use std::future::Future; use std::sync::Arc; +use reqwest::{Client, Method, RequestBuilder}; #[cfg(feature = "tracing")] use tracing as log; -use reqwest::{Client, Method, RequestBuilder}; - use crate::req::RegionalRequester; use crate::util::InsertOnlyCHashMap; -use crate::ResponseInfo; -use crate::Result; -use crate::RiotApiConfig; -use crate::RiotApiError; +use crate::{ResponseInfo, Result, RiotApiConfig, RiotApiError}; /// For retrieving data from the Riot Games API. /// diff --git a/riven/tests/test_ru.rs b/riven/tests/test_ru.rs index 49e2d97..1e945e2 100644 --- a/riven/tests/test_ru.rs +++ b/riven/tests/test_ru.rs @@ -3,11 +3,9 @@ mod async_tests; mod testutils; -use testutils::*; - use colored::*; - use riven::consts::*; +use testutils::*; const ROUTE: PlatformRoute = PlatformRoute::RU; diff --git a/riven/tests/tests_americas.rs b/riven/tests/tests_americas.rs index ac8ed18..6515b4d 100644 --- a/riven/tests/tests_americas.rs +++ b/riven/tests/tests_americas.rs @@ -3,12 +3,10 @@ mod async_tests; mod testutils; -use testutils::*; - use colored::*; - use riven::consts::*; use riven::models::tournament_stub_v5::*; +use testutils::*; const ROUTE: RegionalRoute = RegionalRoute::AMERICAS; diff --git a/riven/tests/tests_asia_jp.rs b/riven/tests/tests_asia_jp.rs index 22bfdb4..5149cc9 100644 --- a/riven/tests/tests_asia_jp.rs +++ b/riven/tests/tests_asia_jp.rs @@ -3,11 +3,9 @@ mod async_tests; mod testutils; -use testutils::*; - use colored::*; - use riven::consts::*; +use testutils::*; const ROUTE: PlatformRoute = PlatformRoute::JP1; diff --git a/riven/tests/tests_europe.rs b/riven/tests/tests_europe.rs index c7976f2..b9b5f2f 100644 --- a/riven/tests/tests_europe.rs +++ b/riven/tests/tests_europe.rs @@ -3,11 +3,9 @@ mod async_tests; mod testutils; -use testutils::*; - use colored::*; - use riven::consts::*; +use testutils::*; const ROUTE: RegionalRoute = RegionalRoute::EUROPE; diff --git a/riven/tests/tests_euw.rs b/riven/tests/tests_euw.rs index 8608e79..35543cc 100644 --- a/riven/tests/tests_euw.rs +++ b/riven/tests/tests_euw.rs @@ -3,11 +3,9 @@ mod async_tests; mod testutils; -use testutils::*; - use colored::*; - use riven::consts::*; +use testutils::*; const ROUTE: PlatformRoute = PlatformRoute::EUW1; diff --git a/riven/tests/tests_euw_tft.rs b/riven/tests/tests_euw_tft.rs index 476533b..1c68f4c 100644 --- a/riven/tests/tests_euw_tft.rs +++ b/riven/tests/tests_euw_tft.rs @@ -3,11 +3,9 @@ mod async_tests; mod testutils; -use testutils::*; - use colored::*; - use riven::consts::*; +use testutils::*; const ROUTE: PlatformRoute = PlatformRoute::EUW1; diff --git a/riven/tests/tests_la1.rs b/riven/tests/tests_la1.rs index 0b146b4..2db98a1 100644 --- a/riven/tests/tests_la1.rs +++ b/riven/tests/tests_la1.rs @@ -3,11 +3,9 @@ mod async_tests; mod testutils; -use testutils::RIOT_API; - use colored::*; - use riven::consts::*; +use testutils::RIOT_API; const ROUTE: PlatformRoute = PlatformRoute::LA1; diff --git a/riven/tests/tests_na.rs b/riven/tests/tests_na.rs index c7b1d84..3a80cb7 100644 --- a/riven/tests/tests_na.rs +++ b/riven/tests/tests_na.rs @@ -3,12 +3,10 @@ mod async_tests; mod testutils; -use testutils::*; - use colored::*; - use riven::consts::*; use riven::models::summoner_v4::*; +use testutils::*; fn validate_summoners(s1: Summoner, s2: Summoner) -> Result<(), String> { rassert_eq!(s1.name, s2.name, "Names didn't match {}.", ""); diff --git a/riven/tests/tests_ph2.rs b/riven/tests/tests_ph2.rs index 527207b..e4d3d89 100644 --- a/riven/tests/tests_ph2.rs +++ b/riven/tests/tests_ph2.rs @@ -3,11 +3,9 @@ mod async_tests; mod testutils; -use testutils::*; - use colored::*; - use riven::consts::*; +use testutils::*; const ROUTE: PlatformRoute = PlatformRoute::PH2; diff --git a/riven/tests/tests_sg2.rs b/riven/tests/tests_sg2.rs index d6437a0..bfcdc19 100644 --- a/riven/tests/tests_sg2.rs +++ b/riven/tests/tests_sg2.rs @@ -3,11 +3,9 @@ mod async_tests; mod testutils; -use testutils::*; - use colored::*; - use riven::consts::*; +use testutils::*; const ROUTE: PlatformRoute = PlatformRoute::SG2; diff --git a/riven/tests/tests_th2.rs b/riven/tests/tests_th2.rs index 3880289..34c134a 100644 --- a/riven/tests/tests_th2.rs +++ b/riven/tests/tests_th2.rs @@ -3,11 +3,9 @@ mod async_tests; mod testutils; -use testutils::*; - use colored::*; - use riven::consts::*; +use testutils::*; const ROUTE: PlatformRoute = PlatformRoute::TH2; diff --git a/riven/tests/tests_tr.rs b/riven/tests/tests_tr.rs index 6805f30..1fce1e0 100644 --- a/riven/tests/tests_tr.rs +++ b/riven/tests/tests_tr.rs @@ -3,12 +3,10 @@ mod async_tests; mod testutils; -use testutils::RIOT_API; - use colored::*; - use riven::consts::*; use riven::models::summoner_v4::Summoner; +use testutils::RIOT_API; const ROUTE: PlatformRoute = PlatformRoute::TR1; diff --git a/riven/tests/tests_val_latam.rs b/riven/tests/tests_val_latam.rs index 14f3d56..fe7ea70 100644 --- a/riven/tests/tests_val_latam.rs +++ b/riven/tests/tests_val_latam.rs @@ -3,11 +3,9 @@ mod async_tests; mod testutils; -use testutils::RIOT_API; - use colored::*; - use riven::consts::*; +use testutils::RIOT_API; const ROUTE: ValPlatformRoute = ValPlatformRoute::LATAM; diff --git a/riven/tests/tests_vn2.rs b/riven/tests/tests_vn2.rs index 38a1fc6..305afc2 100644 --- a/riven/tests/tests_vn2.rs +++ b/riven/tests/tests_vn2.rs @@ -3,11 +3,9 @@ mod async_tests; mod testutils; -use testutils::*; - use colored::*; - use riven::consts::*; +use testutils::*; const ROUTE: PlatformRoute = PlatformRoute::VN2; diff --git a/riven/tests/testutils.rs b/riven/tests/testutils.rs index 59d4bbf..7412903 100644 --- a/riven/tests/testutils.rs +++ b/riven/tests/testutils.rs @@ -3,7 +3,6 @@ use std::future::Future; use lazy_static::lazy_static; - use riven::consts::{PlatformRoute, QueueType, RegionalRoute}; use riven::{RiotApi, RiotApiConfig}; diff --git a/rustfmt.toml b/rustfmt.toml new file mode 100644 index 0000000..3e47d99 --- /dev/null +++ b/rustfmt.toml @@ -0,0 +1,10 @@ +format_code_in_doc_comments = true +format_macro_matchers = true +group_imports = "StdExternalCrate" +hex_literal_case = "Lower" +imports_granularity = "Module" +newline_style = "Unix" +normalize_comments = true +normalize_doc_attributes = true +use_field_init_shorthand = true +use_try_shorthand = true