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
owned: boolWhether 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.
Implementations§
Source§impl PathStep
impl PathStep
Sourcepub fn call(ident: Ident, optional: bool, owned: bool) -> Self
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.
Sourcepub fn yields_owned(&self) -> bool
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.
Sourcepub fn is_optional(&self) -> bool
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.
Sourcepub fn is_plain_field(&self) -> bool
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.
Trait Implementations§
impl Eq for PathStep
impl StructuralPartialEq for PathStep
Auto Trait Implementations§
impl !Send for PathStep
impl !Sync for PathStep
impl Freeze for PathStep
impl RefUnwindSafe for PathStep
impl Unpin for PathStep
impl UnsafeUnpin for PathStep
impl UnwindSafe for PathStep
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<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