Skip to main content

PathStep

Enum PathStep 

Source
pub enum PathStep {
    Call {
        ident: Ident,
        optional: bool,
        owned: bool,
    },
    Field {
        ident: Ident,
        optional: bool,
    },
}
Expand description

One step of a leaf’s UnfoldLeaf::path — how to get from the value reached so far to the next one.

A step is typed rather than a bare ident because a single path may mix the two: an expand_return!(T).fields(fields!(t_to_struct)) leaf calls the value-form accessor, reads a struct field, and may then call that field type’s own accessor — Call(t_to_struct), Field(key_expr), Call(keyexpr_as_str). LeafSource still says what kind of leaf sits at the end of the path; the steps say how it is reached.

Each step also records whether it is optional — its accessor returns Option<…>, or its field is typed Option<…>. A true on a step before the last makes it a nullable nesting step: the emitter matches on it and the None arm short-circuits the whole leaf to null. The flag is carried rather than re-derived so both kinds answer the question the same way and the emitter needs no type walk (an accessor’s Option was already peeled where the step was built).

Variants§

§

Call

Call a #[prebindgen] accessor on the value reached so far: source_module::f(&value).

Fields

§ident: Ident
§optional: bool
§owned: bool

Whether the value this call yields (its return with any Option peeled) is owned rather than a borrow — f(..) -> T / -> Option<T> against -> &T / -> Option<&T>.

Only an OPTIONAL step’s payload can reach an emitter as a bare binding, so this is only ever consulted there: what a Some arm binds is the accessor’s own value, and everything downstream of it — the next step’s receiver, the value form’s argument — needs to know whether it may be moved or has to be borrowed. Recorded here, at the one place the signature is in hand, because deriving it later from the path alone is not possible.

§

Field

Read a struct field of the value reached so far: value.f.

Fields

§ident: Ident
§optional: bool

Implementations§

Source§

impl PathStep

Source

pub fn call(ident: Ident, optional: bool, owned: bool) -> Self

An accessor call step. owned says whether its (Option-peeled) return is an owned value rather than a borrow — see Self::Call::owned.

Source

pub fn yields_owned(&self) -> bool

Whether the value this step yields is owned. A field read composes as &(e).f, so it is a borrow by construction.

Source

pub fn field(ident: Ident, optional: bool) -> Self

A struct-field read step.

Source

pub fn ident(&self) -> &Ident

The step’s ident, whichever kind it is.

Source

pub fn is_optional(&self) -> bool

Whether the step yields an Option — a nullable nesting step when it is not the last on the path.

Source

pub fn is_plain_field(&self) -> bool

Whether the step is a plain (non-optional) field read — a path made only of these renders as value.a.b, needing no nesting match.

Source

pub fn is_field(&self) -> bool

Whether the step is a field read, Option or not.

Trait Implementations§

Source§

impl Clone for PathStep

Source§

fn clone(&self) -> PathStep

Returns a duplicate of the value. Read more
1.0.0 (const: unstable) · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl Debug for PathStep

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
Source§

impl Eq for PathStep

Source§

impl PartialEq for PathStep

Source§

fn eq(&self, other: &PathStep) -> bool

Equality operator ==. Read more
1.0.0 (const: unstable) · Source§

fn ne(&self, other: &Rhs) -> bool

Inequality operator !=. Read more
Source§

impl StructuralPartialEq for PathStep

Auto Trait Implementations§

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> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. 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> IntoEither for T

Source§

fn into_either(self, into_left: bool) -> Either<Self, Self>

Converts 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 more
Source§

fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
where F: FnOnce(&Self) -> bool,

Converts 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
Source§

impl<T> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
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.