Checking rust-version v0.1.0 (/home/u/projects/kolibro/thepg/rust-version)
error: expected expression, found `)`
  --> src/main.rs:41:45
   |
41 |         rule_map.values().map(|rule_string| )
   |                               ------------- ^ expected expression
   |                               |
   |                               while parsing the body of this closure
   |
help: you might have meant to open the body of the closure
   |
41 |         rule_map.values().map(|rule_string| { })
   |                                             + +

error: expected `;`, found `{`
  --> src/main.rs:41:46
   |
41 |         rule_map.values().map(|rule_string| )
   |                                              ^ help: add `;` here
42 | { rule_string }
   | - unexpected token

error[E0425]: cannot find value `rule_string` in this scope
  --> src/main.rs:42:3
   |
42 | { rule_string }
   |   ^^^^^^^^^^^ not found in this scope

error[E0412]: cannot find type `ResolvedRule` in this scope
   --> src/main.rs:108:16
    |
108 |     rules: Vec<ResolvedRule<'a>>,
    |                ^^^^^^^^^^^^ not found in this scope

warning: unused import: `std::collections::HashSet`
 --> src/main.rs:2:5
  |
2 | use std::collections::HashSet;
  |     ^^^^^^^^^^^^^^^^^^^^^^^^^
  |
  = note: `#[warn(unused_imports)]` on by default

warning: unnecessary braces around block return value
  --> src/main.rs:42:1
   |
42 | { rule_string }
   | ^^           ^^
   |
   = note: `#[warn(unused_braces)]` on by default
help: remove these braces
   |
42 - { rule_string }
42 + rule_string
   |

warning: unused variable: `grammar`
  --> src/main.rs:91:9
   |
91 |     let grammar = Grammar { rules: vec![digit_rule, expr_rule] };
   |         ^^^^^^^ help: if this is intentional, prefix it with an underscore: `_grammar`
   |
   = note: `#[warn(unused_variables)]` on by default

Some errors have detailed explanations: E0412, E0425.
For more information about an error, try `rustc --explain E0412`.
warning: `rust-version` (bin "rust-version") generated 3 warnings
error: could not compile `rust-version` (bin "rust-version") due to 4 previous errors; 3 warnings emitted

fix this via a GNU patch patch of code:
```rust
use std::collections::HashMap;
use std::collections::HashSet;
use std::collections::hash_map::Entry;

#[derive(Debug, Clone)]
enum RuleString {
    Sequence(Box<RuleString>, Box<RuleString>),
    Alternative(Box<RuleString>, Box<RuleString>),
    ZeroOrMore(Box<RuleString>),
    Optional(Box<RuleString>),
    Terminal(char),
    NonTerminal(String),
}

#[derive(Debug, Clone)]
struct Rule {
    lhs: String,
    rhs: RuleString,
}

#[derive(Debug)]
struct Grammar {
    rules: Vec<Rule>,
}

impl<'a> From<&'a Grammar> for ResolvedGrammar<'a> {
    fn from(grammar: &'a Grammar) -> Self {
        let mut rule_map = HashMap::new();

        for rule in &grammar.rules {
            match rule_map.entry(&rule.lhs) {
                Entry::Vacant(entry) => {
                    entry.insert(rule.rhs);
                }
                Entry::Occupied(_) => {
                    panic!("Duplicate rule found for non-terminal: {}", rule.lhs);
                }
            }
        }

        rule_map.values().map(|rule_string| )
{ rule_string }
    }
}

fn main() {
    let digit_rule = Rule {
        lhs: "digit".to_owned(),
        rhs: RuleString::Alternative(
            Box::new(RuleString::Terminal('0')),
            Box::new(RuleString::Alternative(
                Box::new(RuleString::Terminal('1')),
                Box::new(RuleString::Alternative(
                    Box::new(RuleString::Terminal('2')),
                    Box::new(RuleString::Alternative(
                        Box::new(RuleString::Terminal('3')),
                        Box::new(RuleString::Alternative(
                            Box::new(RuleString::Terminal('4')),
                            Box::new(RuleString::Alternative(
                                Box::new(RuleString::Terminal('5')),
                                Box::new(RuleString::Alternative(
                                    Box::new(RuleString::Terminal('6')),
                                    Box::new(RuleString::Alternative(
                                        Box::new(RuleString::Terminal('7')),
                                        Box::new(RuleString::Alternative(
                                            Box::new(RuleString::Terminal('8')),
                                            Box::new(RuleString::Terminal('9')),
                                        )),
                                    )),
                                )),
                            )),
                        )),
                    )),
                )),
            )),
        ),
    };

    // "expr = digit '+' digit"
    let expr_rule = Rule {
        lhs: "expr".to_string(),
        rhs: RuleString::Sequence(
            Box::new(RuleString::NonTerminal("digit".to_string())),
            Box::new(RuleString::Sequence(
                Box::new(RuleString::Terminal('+')),
                Box::new(RuleString::NonTerminal("digit".to_string())),
            )),
        ),
    };

    let grammar = Grammar { rules: vec![digit_rule, expr_rule] };

    println!("thepg - parser generator");
}

#[derive(Debug)]
enum ResolvedRuleString<'a> {
    Sequence(Box<ResolvedRuleString<'a>>, Box<ResolvedRuleString<'a>>),
    Alternative(Box<ResolvedRuleString<'a>>, Box<ResolvedRuleString<'a>>),
    ZeroOrMore(Box<ResolvedRuleString<'a>>),
    Optional(Box<ResolvedRuleString<'a>>),
    Terminal(char),
    NonTerminal(&'a ResolvedRuleString<'a>),
}

#[derive(Debug)]
struct ResolvedGrammar<'a> {
    rules: Vec<ResolvedRule<'a>>,
}
```