somelse!
Keep the Some. Diverge on None.
somelse! is a dependency-free, no_std macro that extracts an Option::Some
payload as an expression and requires None to diverge from the current path.
use somelse;
The input runs once. A Some becomes the value of the macro. The else
expression matches None and must leave the current path through return,
break, continue, panic, or another never-returning expression.
Why an expression
Rust's let-else keeps
the inner value in the surrounding scope and requires the failure branch to
diverge. It is a statement, so it cannot be placed directly inside another
expression or function argument.
A match works in those positions but repeats the Some and None structure:
somelse! keeps the same control flow in expression position:
use somelse;
Prefer let-else when a statement is sufficient and match when multiple
branches need meaningful behavior. This macro exists only for concise extraction
where expression placement and caller-selected divergence are both useful.
The name
The name describes the complete domain: Some + else = somelse!.
Contributor checks
Read CONTRIBUTING.md before proposing a change.
The conventional commit linter is written in Rust. Activate the tracked hooks:
Run local validation:
License
Dual-licensed under MIT or Apache 2.0.