From b2020a28a3e93e306d90682fa1a89b1a79777c59 Mon Sep 17 00:00:00 2001 From: Antoni Spaanderman <56turtle56@gmail.com> Date: Mon, 17 Jun 2024 21:56:51 +0200 Subject: [PATCH] use `core::iter::from_fn` --- src/db.rs | 13 ++----------- 1 file changed, 2 insertions(+), 11 deletions(-) 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