chore: address Rust 1.67 clippy lints (#465)

This commit is contained in:
Sanchith Hegde
2023-01-27 12:29:57 +05:30
committed by GitHub
parent 351087fc7f
commit b5720f1e38
33 changed files with 107 additions and 123 deletions

View File

@ -87,7 +87,7 @@ where
serde_json::to_string(&P::try_from(self).change_context(errors::ParsingError)?)
.into_report()
.change_context(errors::ParsingError)
.attach_printable_lazy(|| format!("Unable to convert {:?} to a request", self))
.attach_printable_lazy(|| format!("Unable to convert {self:?} to a request"))
}
fn convert_and_url_encode(&'e self) -> CustomResult<String, errors::ParsingError>
@ -99,7 +99,7 @@ where
serde_urlencoded::to_string(&P::try_from(self).change_context(errors::ParsingError)?)
.into_report()
.change_context(errors::ParsingError)
.attach_printable_lazy(|| format!("Unable to convert {:?} to a request", self))
.attach_printable_lazy(|| format!("Unable to convert {self:?} to a request"))
}
// Check without two functions can we combine this
@ -110,7 +110,7 @@ where
serde_urlencoded::to_string(self)
.into_report()
.change_context(errors::ParsingError)
.attach_printable_lazy(|| format!("Unable to convert {:?} to a request", self))
.attach_printable_lazy(|| format!("Unable to convert {self:?} to a request"))
}
fn encode_to_string_of_json(&'e self) -> CustomResult<String, errors::ParsingError>
@ -120,7 +120,7 @@ where
serde_json::to_string(self)
.into_report()
.change_context(errors::ParsingError)
.attach_printable_lazy(|| format!("Unable to convert {:?} to a request", self))
.attach_printable_lazy(|| format!("Unable to convert {self:?} to a request"))
}
fn encode_to_value(&'e self) -> CustomResult<serde_json::Value, errors::ParsingError>
@ -130,7 +130,7 @@ where
serde_json::to_value(self)
.into_report()
.change_context(errors::ParsingError)
.attach_printable_lazy(|| format!("Unable to convert {:?} to a value", self))
.attach_printable_lazy(|| format!("Unable to convert {self:?} to a value"))
}
fn encode_to_vec(&'e self) -> CustomResult<Vec<u8>, errors::ParsingError>
@ -140,7 +140,7 @@ where
serde_json::to_vec(self)
.into_report()
.change_context(errors::ParsingError)
.attach_printable_lazy(|| format!("Unable to convert {:?} to a value", self))
.attach_printable_lazy(|| format!("Unable to convert {self:?} to a value"))
}
}

View File

@ -143,13 +143,13 @@ mod pii_masking_strategy_tests {
#[test]
fn test_valid_card_number_masking() {
let secret: Secret<String, CardNumber> = Secret::new("1234567890987654".to_string());
assert_eq!("123456**********", format!("{:?}", secret));
assert_eq!("123456**********", format!("{secret:?}"));
}
#[test]
fn test_invalid_card_number_masking() {
let secret: Secret<String, CardNumber> = Secret::new("1234567890".to_string());
assert_eq!("123456****", format!("{:?}", secret));
assert_eq!("123456****", format!("{secret:?}"));
}
/*
@ -172,34 +172,34 @@ mod pii_masking_strategy_tests {
#[test]
fn test_valid_email_masking() {
let secret: Secret<String, Email> = Secret::new("myemail@gmail.com".to_string());
assert_eq!("*******@gmail.com", format!("{:?}", secret));
assert_eq!("*******@gmail.com", format!("{secret:?}"));
}
#[test]
fn test_invalid_email_masking() {
let secret: Secret<String, Email> = Secret::new("myemailgmail.com".to_string());
assert_eq!("*** alloc::string::String ***", format!("{:?}", secret));
assert_eq!("*** alloc::string::String ***", format!("{secret:?}"));
let secret: Secret<String, Email> = Secret::new("myemail@gmail@com".to_string());
assert_eq!("*** alloc::string::String ***", format!("{:?}", secret));
assert_eq!("*** alloc::string::String ***", format!("{secret:?}"));
}
#[test]
fn test_valid_ip_addr_masking() {
let secret: Secret<String, IpAddress> = Secret::new("123.23.1.78".to_string());
assert_eq!("123.**.**.**", format!("{:?}", secret));
assert_eq!("123.**.**.**", format!("{secret:?}"));
}
#[test]
fn test_invalid_ip_addr_masking() {
let secret: Secret<String, IpAddress> = Secret::new("123.4.56".to_string());
assert_eq!("*** alloc::string::String ***", format!("{:?}", secret));
assert_eq!("*** alloc::string::String ***", format!("{secret:?}"));
let secret: Secret<String, IpAddress> = Secret::new("123.4567.12.4".to_string());
assert_eq!("*** alloc::string::String ***", format!("{:?}", secret));
assert_eq!("*** alloc::string::String ***", format!("{secret:?}"));
let secret: Secret<String, IpAddress> = Secret::new("123..4.56".to_string());
assert_eq!("*** alloc::string::String ***", format!("{:?}", secret));
assert_eq!("*** alloc::string::String ***", format!("{secret:?}"));
}
#[test]
@ -208,7 +208,7 @@ mod pii_masking_strategy_tests {
Secret::new("pay_uszFB2QGe9MmLY65ojhT_secret_tLjTz9tAQxUVEFqfmOIP".to_string());
assert_eq!(
"pay_uszFB2QGe9MmLY65ojhT_***************************",
format!("{:?}", secret)
format!("{secret:?}")
);
}
@ -216,6 +216,6 @@ mod pii_masking_strategy_tests {
fn test_invalid_client_secret_masking() {
let secret: Secret<String, IpAddress> =
Secret::new("pay_uszFB2QGe9MmLY65ojhT_secret".to_string());
assert_eq!("*** alloc::string::String ***", format!("{:?}", secret));
assert_eq!("*** alloc::string::String ***", format!("{secret:?}"));
}
}