From f32f49bdb74db450a1492a3f0392c2dca2a3828e 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 --- .gitignore | 1 + pkg/logging/src/lib.rs | 4 +--- 2 files changed, 2 insertions(+), 3 deletions(-) diff --git a/.gitignore b/.gitignore index 1abf5ef3b4..9288036de0 100644 --- a/.gitignore +++ b/.gitignore @@ -3,5 +3,6 @@ **/*.rej **/target **/.vscode +pkg/logging/Cargo.lock src/agent/src/version.rs src/agent/kata-agent.service diff --git a/pkg/logging/src/lib.rs b/pkg/logging/src/lib.rs index 6708529643..65314237cf 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) {