pub use projection_macros::projection;
pub mod prelude {
pub trait OptionProjectable: Sized {
type P;
fn project(f: Option<Self>) -> Self::P;
}
#[doc(hidden)]
pub trait ResultProjectable<E>: Sized {
type P;
fn project(f: Result<Self, E>) -> Self::P;
}
pub trait Projectable {
type P;
fn project(self) -> Self::P;
}
impl<T: OptionProjectable> Projectable for Option<T> {
type P = <T as OptionProjectable>::P;
fn project(self) -> <T as OptionProjectable>::P {
OptionProjectable::project(self)
}
}
impl<E, T: ResultProjectable<E>> Projectable for Result<T, E> {
type P = <T as ResultProjectable<E>>::P;
fn project(self) -> <T as ResultProjectable<E>>::P {
ResultProjectable::project(self)
}
}
}
pub use crate::prelude::*;