Skip to main content

FieldMeta

Struct FieldMeta 

Source
pub struct FieldMeta<'a>(/* private fields */);
Expand description

Metadata for one AST field of one node type.

Use this to build generic inspectors, serializers, or debug UIs that can walk arbitrary grammars.

Implementations§

Source§

impl FieldMeta<'_>

Source

pub fn offset(&self) -> u16

Byte offset of this field within its parent AST node struct.

Source

pub fn kind(&self) -> FieldKind

Semantic kind of this field.

Source

pub fn name(&self) -> &'static str

The field name as a &str.

§Panics

Panics if the grammar table contains invalid UTF-8 in the field name (which would indicate a codegen bug).

Source

pub fn display_name(&self, idx: usize) -> Option<&'static str>

The idx-th display name for enum variants, if present.

§Panics

Panics if the grammar table contains invalid UTF-8 in a display name (which would indicate a codegen bug).

Source

pub fn display_count(&self) -> usize

Number of display names for this field.

Auto Trait Implementations§

§

impl<'a> Freeze for FieldMeta<'a>

§

impl<'a> RefUnwindSafe for FieldMeta<'a>

§

impl<'a> !Send for FieldMeta<'a>

§

impl<'a> !Sync for FieldMeta<'a>

§

impl<'a> Unpin for FieldMeta<'a>

§

impl<'a> UnsafeUnpin for FieldMeta<'a>

§

impl<'a> UnwindSafe for FieldMeta<'a>

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

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

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.