From 3bdee7d2186591ea72b7956dad295cef9a9be354 Mon Sep 17 00:00:00 2001 From: Matthias Beyer Date: Fri, 18 Jun 2021 11:27:32 +0200 Subject: Simplify if-else-block with HashMap::entry() Signed-off-by: Matthias Beyer --- src/container.rs | 7 ++----- 1 file changed, 2 insertions(+), 5 deletions(-) (limited to 'src') diff --git a/src/container.rs b/src/container.rs index 2b3ee84..e73abf5 100644 --- a/src/container.rs +++ b/src/container.rs @@ -512,11 +512,8 @@ impl ContainerListOptionsBuilder { ContainerFilter::LabelName(n) => ("label", n), ContainerFilter::Label(n, v) => ("label", format!("{}={}", n, v)), }; - if let Some(values) = param.get_mut(key) { - values.push(value); - } else { - param.insert(key, vec![value]); - } + + param.entry(key).or_insert(Vec::new()).push(value); } // structure is a a json encoded object mapping string keys to a list // of string values -- cgit v1.2.3