mirror of
https://github.com/pezkuwichain/pezkuwi-subxt.git
synced 2026-04-26 14:37:57 +00:00
Improve decl storage parsing (#4731)
* improve decl storage parsing * remove hidding detail macro * Apply suggestions from code review Co-authored-by: Bastian Köcher <bkchr@users.noreply.github.com>
This commit is contained in:
committed by
Bastian Köcher
parent
fc99887de0
commit
e4f3e85585
@@ -164,39 +164,6 @@ impl ToTokens for OuterAttributes {
|
||||
}
|
||||
}
|
||||
|
||||
#[derive(Debug)]
|
||||
pub struct Opt<P> {
|
||||
pub inner: Option<P>,
|
||||
}
|
||||
|
||||
impl<P: Parse> Parse for Opt<P> {
|
||||
// Note that it cost a double parsing (same as enum derive)
|
||||
fn parse(input: ParseStream) -> Result<Self> {
|
||||
let inner = match input.fork().parse::<P>() {
|
||||
Ok(_item) => Some(input.parse().expect("Same parsing ran before")),
|
||||
Err(_e) => None,
|
||||
};
|
||||
|
||||
Ok(Opt { inner })
|
||||
}
|
||||
}
|
||||
|
||||
impl<P: ToTokens> ToTokens for Opt<P> {
|
||||
fn to_tokens(&self, tokens: &mut TokenStream) {
|
||||
if let Some(ref p) = self.inner {
|
||||
p.to_tokens(tokens);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
impl <P: Clone> Clone for Opt<P> {
|
||||
fn clone(&self) -> Self {
|
||||
Self {
|
||||
inner: self.inner.clone()
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
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()?;
|
||||
|
||||
Reference in New Issue
Block a user