diff --git a/crates/ruma-common/src/events/receipt.rs b/crates/ruma-common/src/events/receipt.rs index bba54877..5acfb295 100644 --- a/crates/ruma-common/src/events/receipt.rs +++ b/crates/ruma-common/src/events/receipt.rs @@ -5,7 +5,7 @@ mod receipt_thread_serde; use std::{ - collections::BTreeMap, + collections::{btree_map, BTreeMap}, ops::{Deref, DerefMut}, }; @@ -54,6 +54,24 @@ impl DerefMut for ReceiptEventContent { } } +impl IntoIterator for ReceiptEventContent { + type Item = (OwnedEventId, Receipts); + type IntoIter = btree_map::IntoIter; + + fn into_iter(self) -> Self::IntoIter { + self.0.into_iter() + } +} + +impl FromIterator<(OwnedEventId, Receipts)> for ReceiptEventContent { + fn from_iter(iter: T) -> Self + where + T: IntoIterator, + { + Self(BTreeMap::from_iter(iter)) + } +} + /// A collection of receipts. pub type Receipts = BTreeMap;