clippy: new fixes

This commit is contained in:
Valentin Tolmer
2024-06-16 11:58:00 +02:00
committed by nitnelave
parent 73686224dd
commit 6f46ffd1e4
6 changed files with 22 additions and 25 deletions
+7 -3
View File
@@ -1,4 +1,4 @@
use std::str::FromStr; use std::{fmt::Display, str::FromStr};
use crate::{ use crate::{
components::{ components::{
@@ -24,9 +24,13 @@ struct JsFile {
contents: Option<Vec<u8>>, contents: Option<Vec<u8>>,
} }
impl ToString for JsFile { impl Display for JsFile {
fn to_string(&self) -> String { fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
write!(
f,
"{}",
self.file.as_ref().map(File::name).unwrap_or_default() self.file.as_ref().map(File::name).unwrap_or_default()
)
} }
} }
+2
View File
@@ -1,3 +1,5 @@
#![allow(clippy::empty_docs)]
use wasm_bindgen::prelude::*; use wasm_bindgen::prelude::*;
#[wasm_bindgen] #[wasm_bindgen]
+5 -11
View File
@@ -53,9 +53,9 @@ impl<'a> std::convert::TryFrom<&'a str> for Uuid {
} }
} }
impl std::string::ToString for Uuid { impl std::fmt::Display for Uuid {
fn to_string(&self) -> String { fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result {
self.0.clone() write!(f, "{}", self.0.as_str())
} }
} }
@@ -559,14 +559,8 @@ mod tests {
#[test] #[test]
fn test_serialized_i64_len() { fn test_serialized_i64_len() {
assert_eq!(SERIALIZED_I64_LEN, Serialized::from(&0i64).0.len()); assert_eq!(SERIALIZED_I64_LEN, Serialized::from(&0i64).0.len());
assert_eq!( assert_eq!(SERIALIZED_I64_LEN, Serialized::from(&i64::MAX).0.len());
SERIALIZED_I64_LEN, assert_eq!(SERIALIZED_I64_LEN, Serialized::from(&i64::MIN).0.len());
Serialized::from(&i64::max_value()).0.len()
);
assert_eq!(
SERIALIZED_I64_LEN,
Serialized::from(&i64::min_value()).0.len()
);
assert_eq!(SERIALIZED_I64_LEN, Serialized::from(&-1000i64).0.len()); assert_eq!(SERIALIZED_I64_LEN, Serialized::from(&-1000i64).0.len());
} }
} }
+4 -4
View File
@@ -445,10 +445,10 @@ impl ConfigOverrider for LdapsOpts {
config.ldaps_options.port = port; config.ldaps_options.port = port;
} }
if let Some(path) = self.ldaps_cert_file.as_ref() { if let Some(path) = self.ldaps_cert_file.as_ref() {
config.ldaps_options.cert_file = path.clone(); config.ldaps_options.cert_file.clone_from(path);
} }
if let Some(path) = self.ldaps_key_file.as_ref() { if let Some(path) = self.ldaps_key_file.as_ref() {
config.ldaps_options.key_file = path.clone(); config.ldaps_options.key_file.clone_from(path);
} }
} }
} }
@@ -470,13 +470,13 @@ impl ConfigOverrider for SmtpOpts {
config.smtp_options.reply_to = Some(reply_to.clone()); config.smtp_options.reply_to = Some(reply_to.clone());
} }
if let Some(server) = &self.smtp_server { if let Some(server) = &self.smtp_server {
config.smtp_options.server = server.clone(); config.smtp_options.server.clone_from(server);
} }
if let Some(port) = self.smtp_port { if let Some(port) = self.smtp_port {
config.smtp_options.port = port; config.smtp_options.port = port;
} }
if let Some(user) = &self.smtp_user { if let Some(user) = &self.smtp_user {
config.smtp_options.user = user.clone(); config.smtp_options.user.clone_from(user);
} }
if let Some(password) = &self.smtp_password { if let Some(password) = &self.smtp_password {
config.smtp_options.password = SecUtf8::from(password.clone()); config.smtp_options.password = SecUtf8::from(password.clone());
+3 -3
View File
@@ -29,9 +29,9 @@ impl std::fmt::Debug for DatabaseUrl {
} }
} }
impl ToString for DatabaseUrl { impl std::fmt::Display for DatabaseUrl {
fn to_string(&self) -> String { fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
self.0.to_string() f.write_fmt(format_args!("{}", self.0))
} }
} }
-3
View File
@@ -31,9 +31,6 @@ use ldap3_proto::proto::{
use std::collections::HashMap; use std::collections::HashMap;
use tracing::{debug, instrument, warn}; use tracing::{debug, instrument, warn};
#[derive(Debug, PartialEq, Eq, Clone)]
struct LdapDn(String);
#[derive(Debug)] #[derive(Debug)]
enum SearchScope { enum SearchScope {
Global, Global,