use crate::regexp::{Flags, Pattern};
#[derive(Debug, Clone)]
pub struct RegExp {
pattern: std::rc::Rc<Pattern>,
escaped: Vec<u16>,
flags: Flags,
source: Vec<u16>,
}
impl RegExp {
#[must_use]
pub fn new(pattern: Pattern, source: Vec<u16>, escaped: Vec<u16>, flags: Flags) -> Self {
Self {
pattern: std::rc::Rc::new(pattern),
escaped,
flags,
source,
}
}
#[must_use]
pub fn source(&self) -> &[u16] {
&self.source
}
#[must_use]
pub fn pattern(&self) -> &Pattern {
&self.pattern
}
#[must_use]
pub fn shared(&self) -> std::rc::Rc<Pattern> {
std::rc::Rc::clone(&self.pattern)
}
#[must_use]
pub fn escaped(&self) -> &[u16] {
&self.escaped
}
#[must_use]
pub fn flags(&self) -> Flags {
self.flags
}
}