From 6e92cabcbe2afa72b865042379f2faed64aa55af Mon Sep 17 00:00:00 2001 From: Drew Short Date: Thu, 6 Dec 2018 16:58:21 -0600 Subject: [PATCH] Cargo Clippy linting suggestions --- src/main.rs | 10 +++++----- src/server/api.rs | 6 +++--- src/server/router.rs | 2 +- 3 files changed, 9 insertions(+), 9 deletions(-) diff --git a/src/main.rs b/src/main.rs index 6a9dfcf..8125a36 100644 --- a/src/main.rs +++ b/src/main.rs @@ -20,14 +20,14 @@ mod config; mod server; -const VERSION: &'static str = env!("CARGO_PKG_VERSION"); -const DEFAULT_HOST: &'static str = "localhost"; +const VERSION: &str = env!("CARGO_PKG_VERSION"); +const DEFAULT_HOST: &str = "localhost"; const DEFAULT_PORT: i16 = 8080; lazy_static! { - static ref DEFAULT_PORT_STR: String = String::from(DEFAULT_PORT.to_string()); + static ref DEFAULT_PORT_STR: String = DEFAULT_PORT.to_string(); static ref DEFAULT_WORKERS: usize = num_cpus::get(); - static ref DEFAULT_WORKERS_STR: String = String::from(DEFAULT_WORKERS.to_string()); + static ref DEFAULT_WORKERS_STR: String = DEFAULT_WORKERS.to_string(); } fn main() { @@ -60,7 +60,7 @@ fn main() { host, port, workers, config_path ); - let actix_server = actix_web::server::new(|| server::router::create()) + let actix_server = actix_web::server::new(server::router::create) .workers(workers) .bind(format!("{}:{}", host, port)); diff --git a/src/server/api.rs b/src/server/api.rs index a3c2197..d8ebb7e 100644 --- a/src/server/api.rs +++ b/src/server/api.rs @@ -29,10 +29,10 @@ fn update_address(address: String) -> String { fn parse_remote_info(remote_info: &str) -> Result { let mut remote_address = String::from(remote_info); - if remote_address.contains(":") { - let last_colon_index = remote_address.rfind(":").unwrap(); + if remote_address.contains(':') { + let last_colon_index = remote_address.rfind(':').unwrap(); let _port = remote_address.split_off(last_colon_index); - if remote_address.starts_with("[") && remote_address.ends_with("]") { + if remote_address.starts_with('[') && remote_address.ends_with(']') { remote_address = String::from(remote_address.trim_matches(|c| c == '[' || c == ']')) } match IpAddr::from_str(&remote_address) { diff --git a/src/server/router.rs b/src/server/router.rs index 905e163..159cc62 100644 --- a/src/server/router.rs +++ b/src/server/router.rs @@ -8,7 +8,7 @@ use crate::server; pub fn create() -> App { actix_web::App::new() .middleware(Logger::default()) - .scope("api/", |api_scope| server::api::route(api_scope)) + .scope("api/", server::api::route) .resource("/health", |r| { r.method(http::Method::GET).with(server::healthcheck) })