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

View file

@ -1,4 +1,4 @@
use std::str::FromStr;
use std::{fmt::Display, str::FromStr};
use crate::{
components::{
@ -24,9 +24,13 @@ struct JsFile {
contents: Option<Vec<u8>>,
}
impl ToString for JsFile {
fn to_string(&self) -> String {
self.file.as_ref().map(File::name).unwrap_or_default()
impl Display for JsFile {
fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
write!(
f,
"{}",
self.file.as_ref().map(File::name).unwrap_or_default()
)
}
}

View file

@ -1,3 +1,5 @@
#![allow(clippy::empty_docs)]
use wasm_bindgen::prelude::*;
#[wasm_bindgen]

View file

@ -53,9 +53,9 @@ impl<'a> std::convert::TryFrom<&'a str> for Uuid {
}
}
impl std::string::ToString for Uuid {
fn to_string(&self) -> String {
self.0.clone()
impl std::fmt::Display for Uuid {
fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result {
write!(f, "{}", self.0.as_str())
}
}
@ -559,14 +559,8 @@ mod tests {
#[test]
fn test_serialized_i64_len() {
assert_eq!(SERIALIZED_I64_LEN, Serialized::from(&0i64).0.len());
assert_eq!(
SERIALIZED_I64_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(&i64::MAX).0.len());
assert_eq!(SERIALIZED_I64_LEN, Serialized::from(&i64::MIN).0.len());
assert_eq!(SERIALIZED_I64_LEN, Serialized::from(&-1000i64).0.len());
}
}

View file

@ -445,10 +445,10 @@ impl ConfigOverrider for LdapsOpts {
config.ldaps_options.port = port;
}
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() {
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());
}
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 {
config.smtp_options.port = port;
}
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 {
config.smtp_options.password = SecUtf8::from(password.clone());

View file

@ -29,9 +29,9 @@ impl std::fmt::Debug for DatabaseUrl {
}
}
impl ToString for DatabaseUrl {
fn to_string(&self) -> String {
self.0.to_string()
impl std::fmt::Display for DatabaseUrl {
fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
f.write_fmt(format_args!("{}", self.0))
}
}

View file

@ -31,9 +31,6 @@ use ldap3_proto::proto::{
use std::collections::HashMap;
use tracing::{debug, instrument, warn};
#[derive(Debug, PartialEq, Eq, Clone)]
struct LdapDn(String);
#[derive(Debug)]
enum SearchScope {
Global,