github dtolnay/syn 1.0.60

latest releases: 2.0.63, 2.0.62, 2.0.61...
3 years ago
  • Provide an idiom for testing exhaustiveness of pattern matches on Expr, Type, Pat, Item, ForeignItem, TraitItem, and ImplItem (#694)

    match expr {
        Expr::Array(e) => {...}
        Expr::Assign(e) => {...}
        ...
        Expr::Yield(e) => {...}
    
        #[cfg(test)]
        Expr::__TestExhaustive(_) => unimplemented!(),
        #[cfg(not(test))]
        _ => { /* some sane fallback */ }
    }

    The above is the only supported idiom for exhaustive matching of those enum. Do not write anything differently as it is not supported.

    The conditional compilation on match-arms lets us fail your tests but not break your library when adding a variant. You will be notified by a test failure when a variant is added, so that you can add code to handle it, but your library will continue to compile and work for downstream users in the interim.

Don't miss a new syn release

NewReleases is sending notifications on new releases.