pub struct Field<'a> {
pub name_in_attr: Cow<'a, String>,
pub ident: &'a Ident,
pub ty: &'a Type,
pub default_expression: Option<DefaultExpression<'a>>,
pub with_path: Cow<'a, Path>,
pub post_transform: Option<&'a PostfixTransform>,
pub skip: bool,
pub multiple: bool,
pub flatten: bool,
}
Expand description
Properties needed to generate code for a field in all the contexts where one may appear.
Fields§
§name_in_attr: Cow<'a, String>
The name presented to the user of the library. This will appear in error messages and will be looked when parsing names.
ident: &'a Ident
The name presented to the author of the library. This will appear in the setters or temporary variables which contain the values.
ty: &'a Type
The type of the field in the input.
default_expression: Option<DefaultExpression<'a>>
§with_path: Cow<'a, Path>
§post_transform: Option<&'a PostfixTransform>
§skip: bool
§multiple: bool
§flatten: bool
If set, this field will be given all unclaimed meta items and will not be exposed as a standard named field.
Implementations§
source§impl<'a> Field<'a>
impl<'a> Field<'a>
sourcepub fn as_name(&'a self) -> Option<&'a str>
pub fn as_name(&'a self) -> Option<&'a str>
Get the name of the meta item that should be matched against input and should be used in diagnostics.
This will be None
if the field is skip
or flatten
, as neither kind of field is addressable
by name from the input meta.
pub fn as_declaration(&'a self) -> Declaration<'a>
pub fn as_flatten_initializer( &'a self, parent_field_names: Vec<&'a str>, ) -> FlattenInitializer<'a>
pub fn as_match(&'a self) -> MatchArm<'a>
pub fn as_initializer(&'a self) -> Initializer<'a>
pub fn as_presence_check(&'a self) -> CheckMissing<'a>
Trait Implementations§
source§impl<'a> UsesTypeParams for Field<'a>
impl<'a> UsesTypeParams for Field<'a>
source§fn uses_type_params<'b>(
&self,
options: &Options,
type_set: &'b IdentSet,
) -> IdentRefSet<'b>
fn uses_type_params<'b>( &self, options: &Options, type_set: &'b IdentSet, ) -> IdentRefSet<'b>
Returns the subset of the queried type parameters that are used by the implementing syntax element. Read more
Auto Trait Implementations§
impl<'a> Freeze for Field<'a>
impl<'a> RefUnwindSafe for Field<'a>
impl<'a> !Send for Field<'a>
impl<'a> !Sync for Field<'a>
impl<'a> Unpin for Field<'a>
impl<'a> UnwindSafe for Field<'a>
Blanket Implementations§
source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more
source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
source§unsafe fn clone_to_uninit(&self, dst: *mut T)
unsafe fn clone_to_uninit(&self, dst: *mut T)
🔬This is a nightly-only experimental API. (
clone_to_uninit
)