#![cfg_attr(not(feature = "std"), no_std)]
#![cfg_attr(feature = "unstable", feature(error_in_core))]
use std::fmt::Display;
pub mod error;
mod slice;
pub mod str;
#[derive(Clone, PartialEq, PartialOrd, Eq, Ord, Debug, Hash)]
pub enum RuleResult<T> {
Matched(usize, T),
Failed,
}
#[allow(clippy::needless_lifetimes)]
pub trait Parse {
type PositionRepr: Display;
fn start<'input>(&'input self) -> usize;
fn is_eof<'input>(&'input self, p: usize) -> bool;
fn position_repr<'input>(&'input self, p: usize) -> Self::PositionRepr;
}
pub trait ParseElem<'input>: Parse {
type Element: Copy;
fn parse_elem(&'input self, pos: usize) -> RuleResult<Self::Element>;
}
pub trait ParseLiteral: Parse {
fn parse_string_literal(&self, pos: usize, literal: &str) -> RuleResult<()>;
}
pub trait ParseSlice<'input>: Parse {
type Slice;
fn parse_slice(&'input self, p1: usize, p2: usize) -> Self::Slice;
}
#[cfg(not(feature = "std"))]
extern crate alloc;
#[cfg(not(feature = "std"))]
extern crate core as std;
#[doc(hidden)]
pub fn call_custom_closure<I, T>(f: impl FnOnce(I, usize) -> RuleResult<T>, input: I, pos: usize) -> RuleResult<T> {
f(input, pos)
}