mirror of
https://github.com/pezkuwichain/pezkuwi-subxt.git
synced 2026-06-09 20:11:09 +00:00
mutate returns a value (#945)
* mutate returns a value * code comment fixes * fix the compile
This commit is contained in:
@@ -251,8 +251,13 @@ impl<T: Trait> Module<T> {
|
||||
fn accumulate_foo(origin: T::Origin, increase_by: T::Balance) -> Result {
|
||||
let _sender = ensure_signed(origin)?;
|
||||
|
||||
let prev = <Foo<T>>::get();
|
||||
// Because Foo has 'default', the type of 'foo' in closure is the raw type instead of an Option<> type.
|
||||
<Foo<T>>::mutate(|foo| *foo = *foo + increase_by);
|
||||
let result = <Foo<T>>::mutate(|foo| {
|
||||
*foo = *foo + increase_by;
|
||||
*foo
|
||||
});
|
||||
assert!(prev + increase_by == result);
|
||||
|
||||
Ok(())
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user