Skip to content

Commit 51ed2cb

Browse files
committed
!simplify
1 parent 37b4e91 commit 51ed2cb

File tree

1 file changed

+12
-18
lines changed
  • crates/matrix-sdk/src/event_cache

1 file changed

+12
-18
lines changed

crates/matrix-sdk/src/event_cache/store.rs

Lines changed: 12 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -542,16 +542,13 @@ pub mod experimental {
542542
type Item = (ChunkPosition, &'a Chunk<T, C>);
543543

544544
fn next(&mut self) -> Option<Self::Item> {
545-
let Some(chunk) = self.chunk else {
546-
return None;
547-
};
548-
549-
let position = self.position;
550-
551-
self.chunk = chunk.previous();
552-
self.position += 1;
545+
self.chunk.map(|chunk| {
546+
let position = self.position;
547+
self.chunk = chunk.previous();
548+
self.position += 1;
553549

554-
Some((position, chunk))
550+
(position, chunk)
551+
})
555552
}
556553
}
557554

@@ -573,16 +570,13 @@ pub mod experimental {
573570
type Item = (ChunkPosition, &'a Chunk<T, C>);
574571

575572
fn next(&mut self) -> Option<Self::Item> {
576-
let Some(chunk) = self.chunk else {
577-
return None;
578-
};
579-
580-
let position = self.position;
581-
582-
self.chunk = chunk.next();
583-
self.position = self.position.saturating_sub(1);
573+
self.chunk.map(|chunk| {
574+
let position = self.position;
575+
self.chunk = chunk.next();
576+
self.position = self.position.saturating_sub(1);
584577

585-
Some((position, chunk))
578+
(position, chunk)
579+
})
586580
}
587581
}
588582

0 commit comments

Comments
 (0)