pub struct FieldDef<'ast> {
pub path: &'ast [FieldPathElem<'ast>],
pub metadata: FieldMetadata<'ast>,
pub value: Option<Ast<'ast>>,
pub pos: TermPos,
}Expand description
A field definition. A field is defined by a dot-separated path of identifier or interpolated strings, a potential value, and associated metadata.
Fields§
§path: &'ast [FieldPathElem<'ast>]A sequence of field path elements, composing the left hand side (with respect to the =)
of the field definition.
§Invariants
Important: The path must be non-empty, or some of FieldDef methods will panic.
metadata: FieldMetadata<'ast>The metadata and the optional value bundled as a field.
value: Option<Ast<'ast>>§pos: TermPosThe position of the whole field definition.
Implementations§
Source§impl FieldDef<'_>
impl FieldDef<'_>
Sourcepub fn path_as_ident(&self) -> Option<LocIdent>
pub fn path_as_ident(&self) -> Option<LocIdent>
Returns the identifier corresponding to this definition if the path is composed of exactly
one element which is a static identifier. Returns None otherwise.
Sourcepub fn name_as_ident(&self) -> Option<LocIdent>
pub fn name_as_ident(&self) -> Option<LocIdent>
Returns the declared field name, that is the last element of the path, as a static
identifier. Returns None if the last element is an expression.
Sourcepub fn root_as_ident(&self) -> Option<LocIdent>
pub fn root_as_ident(&self) -> Option<LocIdent>
Returns the root identifier of the field path, that is the first element of the path, as a
static identifier. Returns None if the first element is an expression.
Trait Implementations§
Source§impl CloneTo for FieldDef<'_>
impl CloneTo for FieldDef<'_>
Source§impl<'ast> TraverseAlloc<'ast, Ast<'ast>> for FieldDef<'ast>
impl<'ast> TraverseAlloc<'ast, Ast<'ast>> for FieldDef<'ast>
Source§fn traverse<F, E>(
self,
alloc: &'ast AstAlloc,
f: &mut F,
order: TraverseOrder,
) -> Result<Self, E>
fn traverse<F, E>( self, alloc: &'ast AstAlloc, f: &mut F, order: TraverseOrder, ) -> Result<Self, E>
Source§fn traverse_ref<S, U>(
&'ast self,
f: &mut dyn FnMut(&'ast Ast<'ast>, &S) -> TraverseControl<S, U>,
scope: &S,
) -> Option<U>
fn traverse_ref<S, U>( &'ast self, f: &mut dyn FnMut(&'ast Ast<'ast>, &S) -> TraverseControl<S, U>, scope: &S, ) -> Option<U>
fn find_map<S>(&'ast self, pred: impl FnMut(&'ast T) -> Option<S>) -> Option<S>where
T: Clone + 'ast,
impl Allocable for FieldDef<'_>
impl<'ast> Eq for FieldDef<'ast>
impl<'ast> StructuralPartialEq for FieldDef<'ast>
Auto Trait Implementations§
impl<'ast> Freeze for FieldDef<'ast>
impl<'ast> RefUnwindSafe for FieldDef<'ast>
impl<'ast> Send for FieldDef<'ast>
impl<'ast> Sync for FieldDef<'ast>
impl<'ast> Unpin for FieldDef<'ast>
impl<'ast> UnsafeUnpin for FieldDef<'ast>
impl<'ast> UnwindSafe for FieldDef<'ast>
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
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
Source§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
Source§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
Source§fn equivalent(&self, key: &K) -> bool
fn equivalent(&self, key: &K) -> bool
key and return true if they are equal.Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self>
fn into_either(self, into_left: bool) -> Either<Self, Self>
self into a Left variant of Either<Self, Self>
if into_left is true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
self into a Left variant of Either<Self, Self>
if into_left(&self) returns true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read more