diff options
author | Matthias Beyer <mail@beyermatthias.de> | 2021-06-18 11:27:32 +0200 |
---|---|---|
committer | Jonas Pommerening <jonas.pommerening@gmail.com> | 2021-06-18 12:08:33 +0200 |
commit | 3bdee7d2186591ea72b7956dad295cef9a9be354 (patch) | |
tree | f018c7a7232df364de127bcb41570417e59e1c57 /src | |
parent | cb80052e8e3a65e01063ccc17f7350aab032bc09 (diff) |
Simplify if-else-block with HashMap::entry()
Signed-off-by: Matthias Beyer <mail@beyermatthias.de>
Diffstat (limited to 'src')
-rw-r--r-- | src/container.rs | 7 |
1 files changed, 2 insertions, 5 deletions
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 |