Skip to content

Commit

Permalink
Don't return trait object for raft::Log::scan()
Browse files Browse the repository at this point in the history
  • Loading branch information
erikgrinaker committed Jan 6, 2024
1 parent 20d220b commit a2822d0
Showing 1 changed file with 2 additions and 4 deletions.
6 changes: 2 additions & 4 deletions src/raft/log.rs
Original file line number Diff line number Diff line change
Expand Up @@ -197,7 +197,7 @@ impl Log {
pub fn scan(
&mut self,
range: impl std::ops::RangeBounds<Index>,
) -> Result<Box<dyn Iterator<Item = Result<Entry>> + '_>> {
) -> Result<impl Iterator<Item = Result<Entry>> + '_> {
let from = match range.start_bound() {
std::ops::Bound::Excluded(i) => std::ops::Bound::Excluded(Key::Entry(*i).encode()?),
std::ops::Bound::Included(i) => std::ops::Bound::Included(Key::Entry(*i).encode()?),
Expand All @@ -210,9 +210,7 @@ impl Log {
std::ops::Bound::Included(Key::Entry(Index::MAX).encode()?)
}
};
Ok(Box::new(
self.engine.scan(from, to).map(|r| r.and_then(|(k, v)| Self::decode_entry(&k, &v))),
))
Ok(self.engine.scan(from, to).map(|r| r.and_then(|(k, v)| Self::decode_entry(&k, &v))))
}

/// Splices a set of entries into the log. The entries must be contiguous,
Expand Down

0 comments on commit a2822d0

Please sign in to comment.