From 5ac611a928b384f2030312a2853219f5853cacf0 Mon Sep 17 00:00:00 2001 From: Chris Bury Date: Fri, 1 Mar 2024 15:53:49 +0000 Subject: [PATCH] Refactored to use the entry api for the crypto_blocks map. --- procfs-core/src/crypto.rs | 7 ++----- 1 file changed, 2 insertions(+), 5 deletions(-) diff --git a/procfs-core/src/crypto.rs b/procfs-core/src/crypto.rs index 16276bf..5e7869f 100644 --- a/procfs-core/src/crypto.rs +++ b/procfs-core/src/crypto.rs @@ -47,11 +47,8 @@ impl FromBufRead for CryptoTable { if name.trim() == "name" { let name = expect!(split.next()).trim().to_string(); let block = CryptoBlock::from_iter(&mut lines, name.as_str())?; - if let Some(v) = crypto_blocks.get_mut(&name) { - v.push(block); - } else { - crypto_blocks.insert(name, vec![block]); - } + let blocks = crypto_blocks.entry(name).or_insert(Vec::new()); + blocks.push(block); } } }