From 33dfcd18252dd8a4845cd58b93bd177ab0dffde9 Mon Sep 17 00:00:00 2001 From: Kjetil Orbekk Date: Sun, 1 Jan 2023 20:47:59 -0500 Subject: Fix clippy warnings --- server/src/auth.rs | 8 +++++++- server/src/error.rs | 6 +++--- server/src/fake_auth.rs | 6 ++++++ server/src/play.rs | 5 +---- 4 files changed, 17 insertions(+), 8 deletions(-) (limited to 'server/src') diff --git a/server/src/auth.rs b/server/src/auth.rs index 76b16cf..173a2b3 100644 --- a/server/src/auth.rs +++ b/server/src/auth.rs @@ -96,6 +96,12 @@ impl SessionId { } } +impl Default for SessionId { + fn default() -> Self { + Self::new() + } +} + impl ToString for SessionId { fn to_string(&self) -> String { self.0.to_string() @@ -116,7 +122,7 @@ fn token_safe_time() -> chrono::Duration { chrono::Duration::seconds(30) } -pub const LOGIN_CALLBACK: &'static str = "/api/login_callback"; +pub const LOGIN_CALLBACK: &str = "/api/login_callback"; fn redirect_url(app_url: &str) -> RedirectUrl { RedirectUrl::new(format!("{}{}", app_url, LOGIN_CALLBACK)).unwrap() } diff --git a/server/src/error.rs b/server/src/error.rs index 7eb5fa2..ebe1d93 100644 --- a/server/src/error.rs +++ b/server/src/error.rs @@ -70,12 +70,12 @@ impl BridgeError { pub fn as_rejection(&self) -> (http::StatusCode, String) { match self { BridgeError::NotLoggedIn => { - (StatusCode::UNAUTHORIZED, format!("Must be logged in")) + (StatusCode::UNAUTHORIZED, "Must be logged in".to_string()) } BridgeError::OpenidRequestTokenError(_) => { - (StatusCode::UNAUTHORIZED, format!("Error fetching token")) + (StatusCode::UNAUTHORIZED, "Error fetching token".to_string()) } - _ => (StatusCode::INTERNAL_SERVER_ERROR, format!("Error: {self}")), + _ => (StatusCode::INTERNAL_SERVER_ERROR, "Error: {self}".to_string()), } } } diff --git a/server/src/fake_auth.rs b/server/src/fake_auth.rs index 6a3ff2c..caea745 100644 --- a/server/src/fake_auth.rs +++ b/server/src/fake_auth.rs @@ -29,6 +29,12 @@ impl FakeAuthenticator { } } +impl Default for FakeAuthenticator { + fn default() -> Self { + Self::new() + } +} + #[async_trait] impl Authenticator for FakeAuthenticator { async fn user_info( diff --git a/server/src/play.rs b/server/src/play.rs index 893cb95..f413a74 100644 --- a/server/src/play.rs +++ b/server/src/play.rs @@ -141,10 +141,7 @@ impl> Table { } pub fn game_in_progress(&self) -> bool { - match &self.state { - TableState::Game(_) => true, - _ => false, - } + matches!(&self.state, TableState::Game(_)) } pub fn game(&self) -> Result<&GameState, BridgeError> { -- cgit v1.2.3