diff --git a/src/scannerless.rs b/src/scannerless.rs index 0f0edc3..4139177 100644 --- a/src/scannerless.rs +++ b/src/scannerless.rs @@ -1,15 +1,35 @@ use crate::rule::{MatchesEmpty, MaybeKnown}; use std::char; +use std::fmt; use std::ops::{self, Bound, RangeBounds}; pub type Context = crate::context::Context>; -#[derive(Copy, Clone, Debug, PartialEq, Eq, PartialOrd, Ord, Hash)] +#[derive(Copy, Clone, PartialEq, Eq, PartialOrd, Ord, Hash)] pub enum Pat { String(S), Range(C, C), } +impl fmt::Debug for Pat { + fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result { + match self { + Pat::String(s) => s.fmt(f), + &Pat::Range(start, end) => { + if start != '\0' { + start.fmt(f)?; + } + f.write_str("..")?; + if end != char::MAX { + f.write_str("=")?; + end.fmt(f)?; + } + Ok(()) + } + } + } +} + impl<'a, C> From<&'a str> for Pat<&'a str, C> { fn from(s: &'a str) -> Self { Pat::String(s)