Skip to content

Commit b78ea8b

Browse files
authored
feat: ad helper append fn (#2186)
1 parent ba9844f commit b78ea8b

File tree

1 file changed

+20
-0
lines changed

1 file changed

+20
-0
lines changed

crates/rpc-types-eth/src/state.rs

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,26 @@ impl StateOverridesBuilder {
3030
self
3131
}
3232

33+
/// Helper `append` function that appends an optional override.
34+
pub fn append_opt<F>(self, f: F) -> Self
35+
where
36+
F: FnOnce() -> Option<(Address, AccountOverride)>,
37+
{
38+
if let Some((add, acc)) = f() {
39+
self.append(add, acc)
40+
} else {
41+
self
42+
}
43+
}
44+
45+
/// Apply a function to the builder, returning the modified builder.
46+
pub fn apply<F>(self, f: F) -> Self
47+
where
48+
F: FnOnce(Self) -> Self,
49+
{
50+
f(self)
51+
}
52+
3353
/// Adds multiple account overrides from an iterator.
3454
pub fn extend<I>(mut self, account_overrides: I) -> Self
3555
where

0 commit comments

Comments
 (0)