Use EncodeLike for storages traits (#3676)

* impl

* patch

* lock

* some refactor

* some avoided copy

* new api without ref for doublemap

* fix

* version bump

* fix

* point to incoming release

* use codec latest

* bumpd impl version

* fix unused

* fix

* Update srml/support/src/storage/mod.rs

Co-Authored-By: Bastian Köcher <bkchr@users.noreply.github.com>
This commit is contained in:
thiolliere
2019-10-01 19:45:24 +02:00
committed by Bastian Köcher
parent 83d4764d46
commit 53e0ddee4e
36 changed files with 489 additions and 465 deletions
@@ -338,7 +338,7 @@ fn decl_store_extra_genesis(
<
#name<#struct_trait #instance> as
#scrate::storage::StorageValue<#typ>
>::put(&v);
>::put::<#typ>(v);
}}
},
DeclStorageTypeInfosKind::Map { key_type, is_linked, .. } => {
@@ -363,7 +363,7 @@ fn decl_store_extra_genesis(
<
#name<#struct_trait #instance> as
#scrate::storage::#map<#key_type, #typ>
>::insert(&k, &v);
>::insert::<#key_type, #typ>(k, v);
});
}}
},
@@ -384,7 +384,7 @@ fn decl_store_extra_genesis(
<
#name<#struct_trait #instance> as
#scrate::storage::StorageDoubleMap<#key1_type, #key2_type, #typ>
>::insert(&k1, &k2, &v);
>::insert::<#key1_type, #key2_type, #typ>(k1, k2, v);
});
}}
},
@@ -927,11 +927,11 @@ fn impl_store_fns(
quote!{
#( #[ #attrs ] )*
pub fn #get_fn<K: #scrate::rstd::borrow::Borrow<#key_type>>(key: K) -> #value_type {
pub fn #get_fn<K: #scrate::codec::EncodeLike<#key_type>>(key: K) -> #value_type {
<
#name<#struct_trait #instance> as
#scrate::storage::#map<#key_type, #typ>
>::get(key.borrow())
>::get(key)
}
}
}
@@ -946,12 +946,10 @@ fn impl_store_fns(
};
quote!{
pub fn #get_fn<KArg1, KArg2>(k1: &KArg1, k2: &KArg2) -> #value_type
pub fn #get_fn<KArg1, KArg2>(k1: KArg1, k2: KArg2) -> #value_type
where
#key1_type: #scrate::rstd::borrow::Borrow<KArg1>,
#key2_type: #scrate::rstd::borrow::Borrow<KArg2>,
KArg1: ?Sized + #scrate::codec::Encode,
KArg2: ?Sized + #scrate::codec::Encode,
KArg1: #scrate::codec::EncodeLike<#key1_type>,
KArg2: #scrate::codec::EncodeLike<#key2_type>,
{
<
#name<#struct_trait #instance> as