[][src]Trait proc_macro_roids::FieldExt

pub trait FieldExt {
    fn type_name(&self) -> &Ident;
fn is_phantom_data(&self) -> bool;
fn contains_tag(&self, namespace: &Path, tag: &Path) -> bool;
fn tag_parameter(&self, namespace: &Path, tag: &Path) -> Option<Meta>;
fn tag_parameters(&self, namespace: &Path, tag: &Path) -> Vec<Meta>; }

Functions to make it ergonomic to inspect Fields 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(&self, namespace: &Path, tag: &Path) -> bool

Returns whether a field contains a given #[namespace(tag)] attribute.

Parameters

  • namespace: The path() of the first-level attribute.
  • tag: The path() of the second-level attribute.

fn tag_parameter(&self, namespace: &Path, tag: &Path) -> Option<Meta>

Returns the parameter from #[namespace(tag(parameter))].

Parameters

  • namespace: The path() of the first-level attribute.
  • tag: The path() of the second-level attribute.

Panics

Panics if there is more than one parameter for the tag.

fn tag_parameters(&self, namespace: &Path, tag: &Path) -> Vec<Meta>

Returns the parameters from #[namespace(tag(param1, param2, ..))].

Parameters

  • namespace: The path() of the first-level attribute.
  • tag: The path() of the second-level attribute.
Loading content...

Implementations on Foreign Types

impl FieldExt for Field[src]

Loading content...

Implementors

Loading content...