Skip to content

Commit

Permalink
style: improve fix for clippy::missing_fields_in_debug
Browse files Browse the repository at this point in the history
  • Loading branch information
paolobarbolini committed Dec 29, 2024
1 parent cc4f137 commit 46528e3
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 8 deletions.
7 changes: 3 additions & 4 deletions src/credentials/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -92,12 +92,11 @@ impl Credentials {
}
}

#[allow(clippy::missing_fields_in_debug)]
impl Debug for Credentials {
fn fmt(&self, f: &mut Formatter<'_>) -> fmt::Result {
f.debug_struct("Credentials")
.field("key", &self.key)
.finish()
.finish_non_exhaustive()
}
}

Expand Down Expand Up @@ -127,14 +126,14 @@ mod tests {
fn debug() {
let credentials = Credentials::new("abcd", "1234");
let debug_output = format!("{credentials:?}");
assert_eq!(debug_output, "Credentials { key: \"abcd\" }");
assert_eq!(debug_output, "Credentials { key: \"abcd\", .. }");
}

#[test]
fn debug_token() {
let credentials = Credentials::new_with_token("abcd", "1234", "xyz");
let debug_output = format!("{credentials:?}");
assert_eq!(debug_output, "Credentials { key: \"abcd\" }");
assert_eq!(debug_output, "Credentials { key: \"abcd\", .. }");
}

#[test]
Expand Down
2 changes: 1 addition & 1 deletion src/credentials/rotating.rs
Original file line number Diff line number Diff line change
Expand Up @@ -151,6 +151,6 @@ mod tests {
let credentials =
RotatingCredentials::new("abcd".into(), "1234".into(), Some("xyz".into()));
let debug_output = format!("{credentials:?}");
assert_eq!(debug_output, "Credentials { key: \"abcd\" }");
assert_eq!(debug_output, "Credentials { key: \"abcd\", .. }");
}
}
5 changes: 2 additions & 3 deletions src/credentials/serde.rs
Original file line number Diff line number Diff line change
Expand Up @@ -90,12 +90,11 @@ impl Ec2SecurityCredentialsMetadataResponse {
}
}

#[allow(clippy::missing_fields_in_debug)]
impl Debug for Ec2SecurityCredentialsMetadataResponse {
fn fmt(&self, f: &mut Formatter<'_>) -> fmt::Result {
f.debug_struct("Ec2SecurityCredentialsMetadataResponse")
.field("key", &self.key)
.finish()
.finish_non_exhaustive()
}
}

Expand Down Expand Up @@ -136,7 +135,7 @@ mod tests {
let debug_output = format!("{deserialized:?}");
assert_eq!(
debug_output,
"Ec2SecurityCredentialsMetadataResponse { key: \"some_access_key\" }"
"Ec2SecurityCredentialsMetadataResponse { key: \"some_access_key\", .. }"
);
}
}

0 comments on commit 46528e3

Please sign in to comment.