mirror of
https://github.com/pezkuwichain/pezkuwi-subxt.git
synced 2026-04-27 13:57:58 +00:00
Refactor decl storage (#3765)
* split implementation in multiple files: * transformation -> genesis_config/ getters.rs instance_trait.rs metadata.rs mod.rs store_trait.rs * mod.rs -> parser.rs * impl.rs -> storage_struct.rs * parser is isolated into parse module, it could be improved as well but this can be done in another PR * modules contains a defintion of decl_storage input which must be ok to work with. * implementation change: * T: Trait might be more often bound to 'static (anyway we only use static one and it is needed for metadata current implementation). * GenesisConfig no longer requires its fields to be Clone (possible since to EncodeLike feature) * builder for map storages must return precise type Vec<(key, value)>
This commit is contained in:
@@ -184,13 +184,15 @@ impl<P: ToTokens> ToTokens for Opt<P> {
|
||||
}
|
||||
}
|
||||
|
||||
pub fn extract_type_option(typ: &syn::Type) -> Option<TokenStream> {
|
||||
pub fn extract_type_option(typ: &syn::Type) -> Option<syn::Type> {
|
||||
if let syn::Type::Path(ref path) = typ {
|
||||
let v = path.path.segments.last()?;
|
||||
if v.value().ident == "Option" {
|
||||
if let syn::PathArguments::AngleBracketed(ref a) = v.value().arguments {
|
||||
let args = &a.args;
|
||||
return Some(quote!{ #args })
|
||||
// Option has only one type argument in angle bracket.
|
||||
if let syn::PathArguments::AngleBracketed(a) = &v.value().arguments {
|
||||
if let syn::GenericArgument::Type(typ) = a.args.last()?.value() {
|
||||
return Some(typ.clone())
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -253,4 +255,4 @@ pub fn expr_contains_ident(expr: &syn::Expr, ident: &Ident) -> bool {
|
||||
|
||||
visit::visit_expr(&mut visit, expr);
|
||||
visit.result
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user