diff --git a/src/db.rs b/src/db.rs index 4563a73..f393a8b 100644 --- a/src/db.rs +++ b/src/db.rs @@ -1,6 +1,7 @@ use anyhow::{Context, Result}; use electrs_rocksdb as rocksdb; +use std::iter; use std::path::Path; use std::sync::atomic::{AtomicBool, Ordering}; @@ -246,16 +247,6 @@ impl DBStore { start: Option<&[u8]>, mut filter_fn: F, ) -> impl Iterator + '_ { - struct Iter(F); - - impl Option, Item> Iterator for Iter { - type Item = Item; - - fn next(&mut self) -> Option { - self.0() - } - } - let mut raw_iter = self.db.raw_iterator_cf_opt(cf, readopts); let mut done = false; @@ -265,7 +256,7 @@ impl DBStore { raw_iter.seek_to_first(); }; - Iter(move || loop { + iter::from_fn(move || loop { // based on ::next break if done { None