Skip to content

Instantly share code, notes, and snippets.

@jcrossley3
Created July 29, 2022 14:08
Show Gist options
  • Save jcrossley3/5e08dbd02b8890aba87d107a4412b397 to your computer and use it in GitHub Desktop.
Save jcrossley3/5e08dbd02b8890aba87d107a4412b397 to your computer and use it in GitHub Desktop.
impl<'a> IntoIterator for &'a ResponsePDU {
type Item = &'a ProvisioningPDU;
type IntoIter = core::slice::Iter<'a, ProvisioningPDU>;
fn into_iter(self) -> core::slice::Iter<'a, ProvisioningPDU> {
let slice = match self {
ResponsePDU::None => &[],
ResponsePDU::One(single) => core::slice::from_ref(single),
ResponsePDU::Two(array) => array.as_slice(),
};
slice.iter()
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment