[−][src]Struct macro_input::FieldDef
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]
path: &'a str,
name: &'a str,
required: bool,
default: DefaultValue
) -> FieldDef<'a>
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]
L: Parse,
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]
V: FromMeta,
try to extract the value from the literal that has the value for this field
Trait Implementations
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]
T: 'static + ?Sized,
impl<T> Borrow<T> for T where
T: ?Sized,
[src]
T: ?Sized,
impl<T> BorrowMut<T> for T where
T: ?Sized,
[src]
T: ?Sized,
pub fn borrow_mut(&mut self) -> &mut T
[src]
impl<T> From<T> for T
[src]
impl<T, U> Into<U> for T where
U: From<T>,
[src]
U: From<T>,
impl<T, U> TryFrom<U> for T where
U: Into<T>,
[src]
U: Into<T>,
type Error = Infallible
The type returned in the event of a conversion error.
pub fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>
[src]
impl<T, U> TryInto<U> for T where
U: TryFrom<T>,
[src]
U: TryFrom<T>,