fn match_prefix(ms: &mut HashSet<Msg>, rules: &Rules, idx: usize) {
  if ms.is_empty() {
    return;
  }
  match *rules.get(&idx).unwrap() {
    Rule::Char(c) => {
      *ms = ms
        .drain()
        .filter_map(|mut m| m.pop().map_or(false, |x| x == c).then(|| m))
        .collect();
    }
    Rule::Seq(ref seq) => match_prefix_seq(ms, rules, seq),
    Rule::Alt(ref a, ref b) => {
      let mut other = ms.clone();
      match_prefix_seq(ms, rules, a);
      match_prefix_seq(&mut other, rules, b);
      ms.extend(other);
    }
  }
}
/// the messages are in reverse, and idx is an index into rules.
the messages are in reverse, and idx is an index into rules.
the messages are in reverse and idx is an index into rules .
fn match_prefix(ms: &mut HashSet<Msg>, rules: &Rules, idx: usize) {
  if ms.is_empty() {
    return;
  }
  match *rules.get(&idx).unwrap() {
    Rule::Char(c) => {
      *ms = ms
        .drain()
        .filter_map(|mut m| m.pop().map_or(false, |x| x == c).then(|| m))
        .collect();
    }
    Rule::Seq(ref seq) => match_prefix_seq(ms, rules, seq),
    Rule::Alt(ref a, ref b) => {
      let mut other = ms.clone();
      match_prefix_seq(ms, rules, a);
      match_prefix_seq(&mut other, rules, b);
      ms.extend(other);
    }
  }
}
fn match_prefix ( ms : & mut HashSet < Msg > , rules : & Rules , idx : usize ) { if ms . is_empty ( ) { return ; } match * rules . get ( & idx ) . unwrap ( ) { Rule :: Char ( c ) => { * ms = ms . drain ( ) . filter_map ( | mut m | m . pop ( ) . map_or ( false , | x | x == c ) . then ( | | m ) ) . collect ( ) ; } Rule :: Seq ( ref seq ) => match_prefix_seq ( ms , rules , seq ) , Rule :: Alt ( ref a , ref b ) => { let mut other = ms . clone ( ) ; match_prefix_seq ( ms , rules , a ) ; match_prefix_seq ( & mut other , rules , b ) ; ms . extend ( other ) ; } } }
the messages are in reverse, and idx is an index into rules.
the messages are in reverse and idx is an index into rules .
ms
&mut HashSet<Msg>
rules
&Rules
idx
usize
ms
&mut HashSet<Msg>
rules
&Rules
idx
usize