From 8d16767bece51bb142e5c3d97a4b09a12f1cfc8e Mon Sep 17 00:00:00 2001 From: bin liu Date: Fri, 16 Oct 2020 15:41:31 +0800 Subject: [PATCH] logging: clear clippy warnings This commit contains two changes: - clear clippy warnigns - add pkg/logging/Cargo.lock to .gitignore Signed-off-by: bin liu Signed-off-by: Chelsea Mafrica --- .gitignore | 1 + pkg/logging/src/lib.rs | 4 +--- 2 files changed, 2 insertions(+), 3 deletions(-) diff --git a/.gitignore b/.gitignore index 76e0fbe59..7e78e3fb8 100644 --- a/.gitignore +++ b/.gitignore @@ -3,6 +3,7 @@ **/*.rej **/target **/.vscode +pkg/logging/Cargo.lock src/agent/src/version.rs src/agent/kata-agent.service src/agent/protocols/src/*.rs diff --git a/pkg/logging/src/lib.rs b/pkg/logging/src/lib.rs index 670852964..65314237c 100644 --- a/pkg/logging/src/lib.rs +++ b/pkg/logging/src/lib.rs @@ -93,9 +93,7 @@ impl HashSerializer { // Take care to only add the first instance of a key. This matters for loggers (but not // Records) since a child loggers have parents and the loggers are serialised child first // meaning the *newest* fields are serialised first. - if !self.fields.contains_key(&key) { - self.fields.insert(key, value); - } + self.fields.entry(key).or_insert(value); } fn remove_field(&mut self, key: &str) {