mirror of
https://github.com/pezkuwichain/pezkuwi-subxt.git
synced 2026-04-26 13:27:57 +00:00
Rework InspectState (#7271)
Reworks `InspectState` in two ways: - Renames `inspect_with` to `inspect_state` to reflect the trait name. - Make `inspect_state` return the result of the closure
This commit is contained in:
@@ -37,11 +37,13 @@ pub trait InspectState<H: Hasher, B: Backend<H>> {
|
||||
///
|
||||
/// Self will be set as read-only externalities and inspection
|
||||
/// closure will be run against it.
|
||||
fn inspect_with<F: FnOnce()>(&self, f: F);
|
||||
///
|
||||
/// Returns the result of the closure.
|
||||
fn inspect_state<F: FnOnce() -> R, R>(&self, f: F) -> R;
|
||||
}
|
||||
|
||||
impl<H: Hasher, B: Backend<H>> InspectState<H, B> for B {
|
||||
fn inspect_with<F: FnOnce()>(&self, f: F) {
|
||||
fn inspect_state<F: FnOnce() -> R, R>(&self, f: F) -> R {
|
||||
ReadOnlyExternalities::from(self).execute_with(f)
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user