ward
This crate exports two macros, which are intended to replicate the functionality of Swift's guard
expression with Option<T> usage. They both do similar things, but the ward! macro technically
has more use cases than the guard! macro, because it returns a value instead of creating a
variable.
Examples
let sut = Some;
// This creates the variable res, which from an Option<T> will return a T if it is Some(T), and will
// otherwise return early from the function.
guard!;
assert_eq!;
The ward! macro, by comparison, just returns the value, without forcing you to make a variable
from it (although we still do in this example):
let sut = Some;
let res = ward!;
assert_eq!;
Both macros also support an else branch, which will run before the method returns early:
let sut = None;
guard!;
unreachable!;