From 0311883a16ca5d6c1f83d0dc4290b9b035845206 Mon Sep 17 00:00:00 2001 From: Andras Schmelczer Date: Sat, 29 Mar 2025 14:04:06 +0000 Subject: [PATCH] Fix lint --- backend/sync_server/src/config/user_config.rs | 2 -- backend/sync_server/src/errors.rs | 14 ++++++++------ backend/sync_server/src/main.rs | 2 +- 3 files changed, 9 insertions(+), 9 deletions(-) diff --git a/backend/sync_server/src/config/user_config.rs b/backend/sync_server/src/config/user_config.rs index 4ee7c72..fea8089 100644 --- a/backend/sync_server/src/config/user_config.rs +++ b/backend/sync_server/src/config/user_config.rs @@ -1,5 +1,3 @@ -use std::default; - use rand::{Rng as _, distributions::Alphanumeric, thread_rng}; use serde::{Deserialize, Serialize}; diff --git a/backend/sync_server/src/errors.rs b/backend/sync_server/src/errors.rs index c5b46c2..69b38d2 100644 --- a/backend/sync_server/src/errors.rs +++ b/backend/sync_server/src/errors.rs @@ -1,3 +1,5 @@ +use std::fmt::Display; + use aide::OperationOutput; use axum::{ Json, @@ -49,16 +51,16 @@ pub struct SerializedError { pub causes: Vec, } -impl ToString for SerializedError { - fn to_string(&self) -> String { - let mut result = self.message.clone(); +impl Display for SerializedError { + fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result { if !self.causes.is_empty() { - result.push_str("\nCauses:\n"); + write!(f, "\nCauses:\n")?; for cause in &self.causes { - result.push_str(&format!("- {}\n", cause)); + write!(f, "{}", &format!("- {cause}\n"))?; } } - result + + Ok(()) } } diff --git a/backend/sync_server/src/main.rs b/backend/sync_server/src/main.rs index 9b2686f..8355654 100644 --- a/backend/sync_server/src/main.rs +++ b/backend/sync_server/src/main.rs @@ -29,7 +29,7 @@ async fn main() -> ExitCode { match result { Ok(()) => ExitCode::SUCCESS, Err(e) => { - eprintln!("{}", e.serialize().to_string()); + eprintln!("{}", e.serialize()); ExitCode::FAILURE } }