pub use prebindgen_flat::shape::Shape as FoldShape;
#[derive(Clone)]
pub struct FoldPlan {
pub target: prebindgen_flat::flat::TypeRef,
pub by_ref: bool,
pub shape: FoldShape,
pub leaves: Vec<FoldLeaf>,
pub selector: Option<usize>,
pub present: Option<usize>,
pub variants: Vec<FoldVariant>,
}
impl FoldPlan {
pub fn produces_option(&self) -> bool {
matches!(self.shape, FoldShape::Optional((), _))
}
}
#[derive(Clone)]
pub struct FoldLeaf {
pub name: syn::Ident,
pub ty: prebindgen_flat::flat::TypeRef,
}
#[derive(Clone)]
pub struct FoldVariant {
pub ctor: Option<syn::Ident>,
pub fallible: bool,
pub clone: bool,
pub inputs: Vec<FoldArg>,
}
#[derive(Clone)]
pub enum FoldArg {
Leaf(usize, bool),
Build(Box<FoldBuild>),
}
#[derive(Clone)]
pub struct FoldBuild {
pub target: prebindgen_flat::flat::TypeRef,
pub by_ref: bool,
pub selector: Option<usize>,
pub variants: Vec<FoldVariant>,
}