From: Ian Jackson Date: Mon, 3 May 2021 14:50:06 +0000 (+0100) Subject: bundles: Break out InstanceBundles::iter() X-Git-Tag: otter-0.6.0~437 X-Git-Url: https://www.chiark.greenend.org.uk/ucgi/~ianmdlvl/git?a=commitdiff_plain;h=15c37b6afd62265db5bd2aeda6bdd322771b6105;p=otter.git bundles: Break out InstanceBundles::iter() Signed-off-by: Ian Jackson --- 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() }