Fix decl_storage map and linked_map for insert_ref (#3316)

* test

* fix

* bumpd version

* Update srml/support/procedural/src/storage/impls.rs

Co-Authored-By: Bastian Köcher <bkchr@users.noreply.github.com>
This commit is contained in:
thiolliere
2019-08-07 11:52:06 +02:00
committed by GitHub
parent 4ed67e03a4
commit 87e72d9327
3 changed files with 42 additions and 13 deletions
@@ -615,6 +615,27 @@ impl<'a, I: Iterator<Item=syn::Meta>> Impls<'a, I> {
storage.put(key_for, &(val, linkage))
}
/// Store a value under this key into the provided storage instance; this can take any reference
/// type that derefs to `T` (and has `Encode` implemented).
/// Store a value under this key into the provided storage instance.
fn insert_ref<Arg, S>(key: &#kty, val: &Arg, storage: &mut S)
where
#typ: AsRef<Arg>,
Arg: ?Sized + #scrate::codec::Encode,
S: #scrate::HashedStorage<#scrate::#hasher>
{
use self::#inner_module::Utils;
let key_for = &*#as_map::key_for(key);
let linkage = match Self::read_with_linkage(storage, key_for) {
// overwrite but reuse existing linkage
Some((_data, linkage)) => linkage,
// create new linkage
None => Self::new_head_linkage(storage, key),
};
storage.put(key_for, &(val, linkage))
}
/// Mutate the value under a key
fn mutate<R, F, S>(key: &#kty, f: F, storage: &mut S) -> R
where