use std::borrow::Cow;
pub use regex::Match;
pub use bird_machine_macros::bird_machine;
pub trait Machine<'t>: Sized {
const ORIGINAL_REGEX: &'static str;
fn captures(text: &'t str) -> Option<Self>;
type CaptureIterator: Iterator<Item = Self>;
fn captures_iter(text: &'t str) -> Self::CaptureIterator;
fn find(text: &'t str) -> Option<Match<'t>>;
fn find_at(text: &'t str, start: usize) -> Option<Match<'t>>;
type FindIterator: Iterator<Item = Match<'t>>;
fn find_iter(text: &'t str) -> Self::FindIterator;
fn is_match(text: &'t str) -> bool;
fn is_match_at(text: &'t str, start: usize) -> bool;
fn replace(text: &'t str, rep: impl Replacer<'t, Self>) -> Cow<'t, str>;
fn replace_all(text: &'t str, rep: impl Replacer<'t, Self>) -> Cow<'t, str>;
fn replacen(text: &'t str, limit: usize, rep: impl Replacer<'t, Self>) -> Cow<'t, str>;
type SplitIterator: Iterator<Item = &'t str>;
fn split(text: &'t str) -> Self::SplitIterator;
type SplitNIterator: Iterator<Item = &'t str>;
fn splitn(text: &'t str, limit: usize) -> Self::SplitNIterator;
}
pub trait Replacer<'t, M: Machine<'t>> {
fn replace_append(&mut self, r#match: &M, dst: &mut String);
}
impl<'t, M: Machine<'t>, S: AsRef<str>, F: FnMut(&M) -> S> Replacer<'t, M> for F {
fn replace_append(&mut self, r#match: &M, dst: &mut String) {
let replaced_with = self(r#match);
let replaced_with: &str = replaced_with.as_ref();
dst.push_str(replaced_with);
}
}