add into function for PrefixIterator (#10614)

* add into function for PrefixIterator

* update with comments

* update with comments
This commit is contained in:
Alex Pozhylenkov
2022-01-09 21:12:21 +02:00
committed by GitHub
parent 02468b803f
commit 03a7738ed8
2 changed files with 17 additions and 32 deletions
@@ -802,6 +802,19 @@ pub struct PrefixIterator<T, OnRemoval = ()> {
phantom: core::marker::PhantomData<OnRemoval>,
}
impl<T, OnRemoval1> PrefixIterator<T, OnRemoval1> {
/// Converts to the same iterator but with the different 'OnRemoval' type
pub fn convert_on_removal<OnRemoval2>(self) -> PrefixIterator<T, OnRemoval2> {
PrefixIterator::<T, OnRemoval2> {
prefix: self.prefix,
previous_key: self.previous_key,
drain: self.drain,
closure: self.closure,
phantom: Default::default(),
}
}
}
/// Trait for specialising on removal logic of [`PrefixIterator`].
pub trait PrefixIteratorOnRemoval {
/// This function is called whenever a key/value is removed.