1#![feature(round_char_boundary)]
2#![warn(missing_docs)]
3#![doc = include_str!("../readme.md")]
4
5pub mod byte;
6pub mod parser;
7pub mod pipe;
8pub mod str;
9mod tag;
10mod take;
11
12pub use self::{pipe::*, tag::*, take::*};
13use fatal_error::{FatalError, NeverErr};
14
15pub type Result<R, O, E> = std::result::Result<(R, O), FatalError<E>>;
23
24pub trait Pipe<I, O, E = NeverErr, R = I> {
26 fn apply(&mut self, input: I) -> Result<R, O, E>;
33}
34
35impl<I, O, E, R, F> Pipe<I, O, E, R> for F
37where
38 F: FnMut(I) -> Result<R, O, E>,
39{
40 fn apply(&mut self, input: I) -> Result<R, O, E> { (self)(input) }
41}
42
43impl<I, E> Pipe<I, (), E> for () {
44 fn apply(&mut self, input: I) -> Result<I, (), E> { Ok((input, ())) }
45}