Skip to main content

FoldPlan

Struct FoldPlan 

Source
pub struct FoldPlan {
    pub target: TypeRef,
    pub by_ref: bool,
    pub shape: FoldShape,
    pub leaves: Vec<FoldLeaf>,
    pub selector: Option<usize>,
    pub present: Option<usize>,
    pub variants: Vec<FoldVariant>,
}
Expand description

A resolved expansion for one (function, parameter).

Fields§

§target: TypeRef

Owned type the core construct produces — what the underlying call needs (before any Self::shape wrapping). A reading: target.spell() for generated Rust, target.key() for a lookup.

§by_ref: bool

True when the original parameter was &T / Option<&T>: the call receives &folded (or folded.as_ref() when also optional). A call-site concern (the resolver’s &_ handler shares the inner converter the same way), not part of the fold.

§shape: FoldShape

Outer shape over the core construct (Construct for a plain T/&T param; Optional(Construct) for Option<T>/Option<&T>).

§leaves: Vec<FoldLeaf>

Flattened wire leaves, in foreign-signature order.

§selector: Option<usize>

Index into Self::leaves of the selector leaf; None for a single constructor (the sole variant is applied unconditionally). Under an Optional shape the selector also encodes absence: -1 = None, 0..n-1 = the taken arm.

§present: Option<usize>

Index into Self::leaves of the explicit presence-flag (bool) leaf for a multi-argument Optional shape (Option<T> built from a constructor taking ≥2 args): the flag decides Some/None, the arg leaves are plain (non-Option). None for a non-optional fold or the legacy single-arg Optional (where presence rides the sole leaf’s own Option-ness). A separate flag avoids boxing a nullable primitive arg (e.g. Option<i32>Integer?) on the wire.

§variants: Vec<FoldVariant>

Dispatch arms — one for a single constructor, selector order for a combined one.

Implementations§

Source§

impl FoldPlan

Source

pub fn produces_option(&self) -> bool

True when the fold produces an Option<_> (outermost shape layer is Optional) — drives the by-ref call-site form (folded.as_ref()).

Trait Implementations§

Source§

impl Clone for FoldPlan

Source§

fn clone(&self) -> FoldPlan

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

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.