Skip to content

Instantly share code, notes, and snippets.

View bvssvni's full-sized avatar

Sven Nilsen bvssvni

View GitHub Profile
@bvssvni
bvssvni / gist:9674632
Last active December 23, 2023 22:56
A Rust Chain Macro
//! Chain macro in Rust
//!
//! A typical usage is to avoid nested match expressions.
//!
//! Supports:
//! - Pattern matching
//! - Or expressions (A | B => ...)
//! - Guarded statements (x if <cond> => ...)
//! - Implicit else (requires all arms to return same type)