[−][src]Trait proc_macro_roids::FieldExt
Functions to make it ergonomic to inspect Field
s and their attributes.
Required methods
fn type_name(&self) -> &Ident
Returns the simple type name of a field.
For example, the PhantomData
in std::marker::PhantomData<T>
.
fn is_phantom_data(&self) -> bool
Returns whether the field is PhantomData
.
Note that the detection is a string comparison instead of a type ID comparison, so is prone to inaccurate detection, for example:
use std::marker::PhantomData as GhostData;
use other_crate::OtherType as PhantomData;
fn contains_tag<NS, Tag>(&self, namespace: NS, tag: Tag) -> bool where
Ident: PartialEq<NS>,
Ident: PartialEq<Tag>,
Ident: PartialEq<NS>,
Ident: PartialEq<Tag>,
Returns whether a field contains a given #[namespace(tag)]
attribute.
Parameters
namespace
: Thename()
of the first-level attribute.tag
: Thename()
of the second-level attribute.
fn tag_parameter<NS, Tag>(&self, namespace: NS, tag: Tag) -> Option<Meta> where
NS: Display,
Tag: Display,
Ident: PartialEq<NS>,
Ident: PartialEq<Tag>,
NS: Display,
Tag: Display,
Ident: PartialEq<NS>,
Ident: PartialEq<Tag>,
Returns the parameter from #[namespace(tag(parameter))]
.
Parameters
namespace
: Thename()
of the first-level attribute.tag
: Thename()
of the second-level attribute.
Panics
Panics if there is more than one parameter for the tag.
fn tag_parameters<NS, Tag>(&self, namespace: NS, tag: Tag) -> Vec<Meta> where
NS: Display,
Tag: Display,
Ident: PartialEq<NS>,
Ident: PartialEq<Tag>,
NS: Display,
Tag: Display,
Ident: PartialEq<NS>,
Ident: PartialEq<Tag>,
Returns the parameters from #[namespace(tag(param1, param2, ..))]
.
Parameters
namespace
: Thename()
of the first-level attribute.tag
: Thename()
of the second-level attribute.
Implementations on Foreign Types
impl FieldExt for Field
[src]
fn type_name(&self) -> &Ident
[src]
fn is_phantom_data(&self) -> bool
[src]
fn contains_tag<NS, Tag>(&self, namespace: NS, tag: Tag) -> bool where
Ident: PartialEq<NS>,
Ident: PartialEq<Tag>,
[src]
Ident: PartialEq<NS>,
Ident: PartialEq<Tag>,
fn tag_parameter<NS, Tag>(&self, namespace: NS, tag: Tag) -> Option<Meta> where
NS: Display,
Tag: Display,
Ident: PartialEq<NS>,
Ident: PartialEq<Tag>,
[src]
NS: Display,
Tag: Display,
Ident: PartialEq<NS>,
Ident: PartialEq<Tag>,
fn tag_parameters<NS, Tag>(&self, namespace: NS, tag: Tag) -> Vec<Meta> where
NS: Display,
Tag: Display,
Ident: PartialEq<NS>,
Ident: PartialEq<Tag>,
[src]
NS: Display,
Tag: Display,
Ident: PartialEq<NS>,
Ident: PartialEq<Tag>,