use crate::errors::Result;
use crate::Decorator;
use std::marker::PhantomData;
pub trait StepIndexBase {
const ID: usize;
}
pub struct FirstStepIndex;
impl StepIndexBase for FirstStepIndex {
const ID: usize = 1;
}
pub struct StepIndex<T>(pub(crate) PhantomData<T>);
impl<T> StepIndexBase for StepIndex<T>
where
T: StepIndexBase,
{
const ID: usize = T::ID + 1;
}
pub trait FromStep<T> {}
pub trait AnyStep {}
impl<D, T> FromStep<D> for T where T: AnyStep {}
impl<T, O, F> Decorator<T, O> for F
where
F: FnMut(T) -> Result<O>,
{
#[inline]
fn produce(&mut self, previous: T) -> Result<O> {
self(previous)
}
}