pub fn error<I, O, E, R, F>(f: F) -> impl Pipe<I, O, E, R>where
F: FnMut() -> FatalError<E>,Expand description
creates a pipe that always return an error
#[derive(Debug, PartialEq)]
enum Error {
Tag(TagStrError),
Incomplete(Incomplete),
Other
}
impl From<TagStrError> for Error { fn from(e: TagStrError) -> Error { Error::Tag(e)} }
impl From<Incomplete> for Error { fn from(e: Incomplete) -> Error { Error::Incomplete(e) } }
impl std::error::Error for Error {}
impl std::fmt::Display for Error {
fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
write!(f, "{self:?}")
}
}
assert_eq!(tag::<Error, _, _>("a").or(error(|| FatalError::Fatal(Error::Other))).apply("b"), Err(FatalError::Fatal(Error::Other)));