mirror of
https://github.com/pezkuwichain/pezkuwi-subxt.git
synced 2026-05-30 03:31:05 +00:00
Extract search of digest item into Digest::log() function (#874)
* Digest::log fn * change DigestItem::log impl
This commit is contained in:
committed by
Gav Wood
parent
187c232629
commit
200a716a1a
@@ -503,6 +503,13 @@ pub trait Digest: Member + Default {
|
||||
fn logs(&self) -> &[Self::Item];
|
||||
/// Push new digest item.
|
||||
fn push(&mut self, item: Self::Item);
|
||||
|
||||
/// Get reference to the first digest item that matches the passed predicate.
|
||||
fn log<T, F: Fn(&Self::Item) -> Option<&T>>(&self, predicate: F) -> Option<&T> {
|
||||
self.logs().iter()
|
||||
.filter_map(predicate)
|
||||
.next()
|
||||
}
|
||||
}
|
||||
|
||||
/// Single digest item. Could be any type that implements `Member` and provides methods
|
||||
|
||||
Reference in New Issue
Block a user