/// Reusable base for `FromDeriveInput`, `FromVariant`, `FromField`, and other top-level /// `From*` traits. #[derive(Debug, Clone)] pubstruct OuterFrom { /// The field on the target struct which should receive the type identifier, if any. pub ident: Option<Ident>,
/// The field on the target struct which should receive the type attributes, if any. pub attrs: Option<AttrsField>,
pub container: Core,
/// The attribute names that should be searched. pub attr_names: PathList,
/// The attribute names that should be forwarded. The presence of the word with no additional /// filtering will cause _all_ attributes to be cloned and exposed to the struct after parsing. pub forward_attrs: Option<ForwardAttrsFilter>,
/// Whether or not the container can be made through conversion from the type `Ident`. pub from_ident: bool,
}
impl ParseAttribute for OuterFrom { fn parse_nested(&mutself, mi: &Meta) -> Result<()> { let path = mi.path(); if path.is_ident("attributes") { self.attr_names = FromMeta::from_meta(mi)?;
} elseif path.is_ident("forward_attrs") { self.forward_attrs = FromMeta::from_meta(mi)?;
} elseif path.is_ident("from_ident") { // HACK: Declaring that a default is present will cause fields to // generate correct code, but control flow isn't that obvious. self.container.default = Some(DefaultExpression::Trait { // Use the span of the `from_ident` keyword so that errors in generated code // caused by this will point back to the correct location.
span: path.span(),
}); self.from_ident = true;
} else { returnself.container.parse_nested(mi);
}
Ok(())
}
}
Die Informationen auf dieser Webseite wurden
nach bestem Wissen sorgfältig zusammengestellt. Es wird jedoch weder Vollständigkeit, noch Richtigkeit,
noch Qualität der bereit gestellten Informationen zugesichert.
Bemerkung:
Die farbliche Syntaxdarstellung und die Messung sind noch experimentell.