summaryrefslogtreecommitdiff
path: root/src/channel/history.rs
diff options
context:
space:
mode:
authorOwen Jacobson <owen@grimoire.ca>2024-10-30 01:14:02 -0400
committerOwen Jacobson <owen@grimoire.ca>2024-10-30 01:14:02 -0400
commitffba911ba5240f67cc616b2cc2eaf7c730ebbde8 (patch)
tree23df60d7af53b4f5fe14fec4e77f64188f4a9f37 /src/channel/history.rs
parent36e659e971d091cfcbe370f5e45a0d01102d2e83 (diff)
Avoid hard-coding the assumption that delete comes-after create.
I mean, it always does, but I'd rather get a panic during message/channel reconstruction than wrong results if that assumption is ever violated inadvertently.
Diffstat (limited to 'src/channel/history.rs')
-rw-r--r--src/channel/history.rs6
1 files changed, 5 insertions, 1 deletions
diff --git a/src/channel/history.rs b/src/channel/history.rs
index 4b9fcc7..dda7bb9 100644
--- a/src/channel/history.rs
+++ b/src/channel/history.rs
@@ -1,3 +1,5 @@
+use itertools::Itertools as _;
+
use super::{
event::{Created, Deleted, Event},
Channel, Id,
@@ -41,7 +43,9 @@ impl History {
// Event factories
impl History {
pub fn events(&self) -> impl Iterator<Item = Event> {
- [self.created()].into_iter().chain(self.deleted())
+ [self.created()]
+ .into_iter()
+ .merge_by(self.deleted(), Sequence::merge)
}
fn created(&self) -> Event {