bijective 0.1.0

Compile-time enforcement of surjective, injective, and bijective properties on enum-to-enum match expressions
Documentation
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
use syn::{ExprMatch, visit::Visit};

pub struct MatchFinder<'ast> {
    pub found: Option<&'ast ExprMatch>,
}

impl<'ast> Visit<'ast> for MatchFinder<'ast> {
    fn visit_expr_match(&mut self, node: &'ast ExprMatch) {
        if self.found.is_none() {
            self.found = Some(node);
            // Don't delegate to the default impl — stops recursion into nested
            // matches inside arms, so we always capture the outermost one.
        }
    }
}