Flatten exchange keys return
@@ -115,13 +115,10 @@ impl<Link> KeyStore<Link> {
}
pub fn exchange_keys(&self) -> Vec<(Identifier, Vec<u8>)> {
- let mut keys: Vec<(Identifier, Vec<u8>)> =
- self.keys.iter().map(|(id, pk)| (*id, pk.as_slice().to_vec())).collect();
-
- let psks: Vec<(Identifier, Vec<u8>)> = self.psks.iter().map(|(id, psk)| ((*id).into(), psk.to_vec())).collect();
-
- keys.extend(psks);
- keys
+ self.keys.iter().zip(self.psks.iter())
+ .map(|(keys, psks)| vec![(*keys.0, keys.1.as_slice().to_vec()), ((*psks.0).into(), psks.1.to_vec())])
+ .flatten()
+ .collect()
}
pub fn cursors(&self) -> impl Iterator<Item = (&Identifier, &Cursor<Link>)> {
