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

Functions to make it ergonomic to inspect Fields and their attributes.

Required Methods§

source

fn type_name(&self) -> &Ident

Returns the simple type name of a field.

For example, the PhantomData in std::marker::PhantomData<T>.

source

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;
source

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.
source

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

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

Parameters
  • namespace: The path() of the first-level attribute.
Panics

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

source

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

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

Parameters
  • namespace: The path() of the first-level attribute.
source

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.

source

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.

Implementations on Foreign Types§

source§

impl FieldExt for Field

source§

fn type_name(&self) -> &Ident

source§

fn is_phantom_data(&self) -> bool

source§

fn contains_tag(&self, namespace: &Path, tag: &Path) -> bool

source§

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

source§

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

source§

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

source§

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

Implementors§