[][src]Struct macro_input::FieldDef

pub struct FieldDef<'a> {
    pub path: &'a str,
    pub name: &'a str,
    pub required: bool,
    pub default: DefaultValue,
}

a field definition

Example

use macro_input::{DefaultValue, FieldDef};

const BAR_FIELD: FieldDef = FieldDef::new("foo", "bar", false, DefaultValue::Bool(None));
const BAZ_FIELD: FieldDef = FieldDef::new("foo", "baz", false, DefaultValue::Str(None));

Fields

path: &'a str

the path/namespace of the field

name: &'a str

the name of the field

required: bool

whether or not this field is required

default: DefaultValue

the typed default value

Implementations

impl<'a> FieldDef<'a>[src]

pub const fn new(
    path: &'a str,
    name: &'a str,
    required: bool,
    default: DefaultValue
) -> FieldDef<'a>
[src]

create a new field definition

pub fn strip(&self, attrs: &mut Vec<Attribute, Global>)[src]

strip the attributes for this field away

pub fn get_meta(&self, attrs: &[Attribute]) -> Option<Meta>[src]

try to find the meta that has the value for this field

pub fn get_lit(&self, attrs: &[Attribute]) -> Option<Lit>[src]

try to find the literal that has the value for this field

pub fn get<L>(&self, attrs: &[Attribute]) -> Option<L> where
    L: Parse
[src]

try to parse the literal that has the value for this field

pub fn get_value<V>(&self, attrs: &[Attribute]) -> Result<V, Error> where
    V: FromMeta
[src]

try to extract the value from the literal that has the value for this field

Trait Implementations

impl<'_> Lint<Vec<Attribute, Global>> for FieldDef<'_>[src]

Auto Trait Implementations

impl<'a> RefUnwindSafe for FieldDef<'a>[src]

impl<'a> !Send for FieldDef<'a>[src]

impl<'a> !Sync for FieldDef<'a>[src]

impl<'a> Unpin for FieldDef<'a>[src]

impl<'a> UnwindSafe for FieldDef<'a>[src]

Blanket Implementations

impl<T> Any for T where
    T: 'static + ?Sized
[src]

impl<T> Borrow<T> for T where
    T: ?Sized
[src]

impl<T> BorrowMut<T> for T where
    T: ?Sized
[src]

impl<T> From<T> for T[src]

impl<T, U> Into<U> for T where
    U: From<T>, 
[src]

impl<T, U> TryFrom<U> for T where
    U: Into<T>, 
[src]

type Error = Infallible

The type returned in the event of a conversion error.

impl<T, U> TryInto<U> for T where
    U: TryFrom<T>, 
[src]

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.