Macro coalesce
coalesce!() { /* proc-macro */ }
Expand description
devela_macros
Returns the first non-empty argument.
If all arguments are empty, the macro returns nothing.
This macro is inspired by the SQL COALESCE
function, which returns the first
non-null value from a list of arguments, or null if all the arguments are null.
ยงExamples
use devela_macros::coalesce;
fn main() {
assert_eq!(1, coalesce!(1));
assert_eq!("second", coalesce!(, "second", "third"));
assert_eq!((), coalesce!(, , ()));
assert_eq!('a', coalesce!(, 'a', 2, "third", ()));
coalesce!( , ,); // returns nothing
}