use crate::Visitor;
/// A type buildable from a walker.
pub trait Build<'value, 'ctx>: Sized {
type Error;
/// The builder that can be used to build a value.
type Builder: Builder<'value, 'ctx, Value = Self, Error = Self::Error>;
}
/// Extension to [`Visitor`] that allows constructing and finishing the visitor.
pub trait Builder<'value, 'ctx> {
type Error;
/// Type to be built.
type Value: Sized;
/// Init a new builder.
fn init() -> Self
where
Self: Sized;
/// As a visitor.
fn as_visitor<WalkerErr: 'value>(
&mut self,
) -> &mut dyn Visitor<'value, 'ctx, WalkerErr, Error = Self::Error>;
/// Finish the value.
fn finish(self) -> Result<Self::Value, Self::Error>
where
Self: Sized;
}