1
0
mirror of https://github.com/romanz/electrs.git synced 2024-11-19 09:54:09 +01:00

use core::iter::from_fn

This commit is contained in:
Antoni Spaanderman 2024-06-17 21:56:51 +02:00
parent ff2ef82859
commit b2020a28a3
No known key found for this signature in database
GPG Key ID: AE0B68E552E5DF8C

View File

@ -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<Item = [u8; N]> + '_ {
struct Iter<F>(F);
impl<F: FnMut() -> Option<Item>, Item> Iterator for Iter<F> {
type Item = Item;
fn next(&mut self) -> Option<Self::Item> {
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 <DBIteratorWithThreadMode as Iterator>::next
break if done {
None