use crate::Span;
#[derive(Debug, Clone, Copy, PartialEq, Eq)]
#[cfg_attr(feature = "arbitrary", derive(arbitrary::Arbitrary))]
pub struct Boundary {
pub kind: BoundaryKind,
pub unicode_aware: bool,
pub span: Span,
}
impl Boundary {
pub fn new(kind: BoundaryKind, unicode_aware: bool, span: Span) -> Self {
Boundary { kind, unicode_aware, span }
}
pub fn kind(&self) -> BoundaryKind {
self.kind
}
#[cfg(feature = "dbg")]
pub(super) fn pretty_print(&self, buf: &mut crate::PrettyPrinter) {
match self.kind {
BoundaryKind::Start => buf.push('^'),
BoundaryKind::End => buf.push('$'),
BoundaryKind::Word => buf.push('%'),
BoundaryKind::NotWord => buf.push_str("!%"),
BoundaryKind::WordStart => buf.push_str("<"),
BoundaryKind::WordEnd => buf.push_str(">"),
}
}
}
#[derive(Debug, Clone, Copy, PartialEq, Eq)]
#[cfg_attr(feature = "arbitrary", derive(arbitrary::Arbitrary))]
pub enum BoundaryKind {
Start,
End,
Word,
NotWord,
WordStart,
WordEnd,
}