From 15c37b6afd62265db5bd2aeda6bdd322771b6105 Mon Sep 17 00:00:00 2001 From: Ian Jackson Date: Mon, 3 May 2021 15:50:06 +0100 Subject: [PATCH] bundles: Break out InstanceBundles::iter() Signed-off-by: Ian Jackson --- src/bundles.rs | 13 +++++++++---- 1 file changed, 9 insertions(+), 4 deletions(-) diff --git a/src/bundles.rs b/src/bundles.rs index 0d003595..e131d7a5 100644 --- a/src/bundles.rs +++ b/src/bundles.rs @@ -203,12 +203,17 @@ fn incorporate_bundle(ib: &mut InstanceBundles, ig: &mut Instance, impl InstanceBundles { pub fn new() -> Self { InstanceBundles{ bundles: default() } } - pub fn list(&self) -> MgmtBundleList { + fn iter(&self) -> impl Iterator { self.bundles.iter().enumerate().filter_map(|(index, slot)| { - let note = slot.as_ref()?; + let Note { kind, ref state } = *slot.as_ref()?; let index = index.try_into().unwrap(); - Some((Id { index, kind: note.kind }, - note.state.clone())) + Some((Id { index, kind }, state)) + }) + } + + pub fn list(&self) -> MgmtBundleList { + self.iter().map(|(id, state)| { + (id, state.clone()) }).collect() } -- 2.30.2