Struct redfa::derivatives::Derivatives
source · pub struct Derivatives<T, R> {
pub d: Vec<(Vec<T>, R)>,
pub rest: R,
}
Expand description
The set of some object’s derivatives with respect to an alphabet T
.
Fields§
§d: Vec<(Vec<T>, R)>
Holds a set of pairs (chars, derivative)
, meaning that the derivative
with respect to any element of chars
is derivative
.
rest: R
The derivative with respect to any character not listed in d
.
Implementations§
source§impl<T, R> Derivatives<T, R>
impl<T, R> Derivatives<T, R>
sourcepub fn map<F: FnMut(R) -> R>(self, f: F) -> Derivatives<T, R>
pub fn map<F: FnMut(R) -> R>(self, f: F) -> Derivatives<T, R>
Examples found in repository?
examples/test.rs (line 15)
5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25
fn main() {
let stdin = std::io::stdin();
for line in stdin.lock().lines() {
let line = line.unwrap();
match line.trim().parse::<Regex<char>>() {
Err(e) => println!("error: {}", e),
Ok(x) => {
println!("ok: {:?}", x);
let x = x.normalize();
println!("{:?}", x);
println!("{:?}", x.derivative().map(Normalize::normalize));
let (dfa, _mapping) = Dfa::from_derivatives(vec![x, Regex::Null]);
let dfa = dfa.map(|reg| reg.nullable());
println!("DFA: {:?}\n", dfa);
let mdfa = dfa.minimize().map(|x| *x);
println!("Minimized DFA: {:?}\n", mdfa);
println!("dfa == mdfa: {:?}\n", dfa == mdfa);
}
}
}
}
Trait Implementations§
Auto Trait Implementations§
impl<T, R> RefUnwindSafe for Derivatives<T, R>where
R: RefUnwindSafe,
T: RefUnwindSafe,
impl<T, R> Send for Derivatives<T, R>
impl<T, R> Sync for Derivatives<T, R>
impl<T, R> Unpin for Derivatives<T, R>
impl<T, R> UnwindSafe for Derivatives<T, R>where
R: UnwindSafe,
T: UnwindSafe,
Blanket Implementations§
source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more