This is a bit of code I wrote in my Rust program:

macro_rules! tern {
(true, $one:expr, $_:expr) => { $one };
(false, $_:expr, $two:expr) => { $two };
}

This seems so blatantly useful it seems like it *ought* to be in the standard library, but to my knowledge it is not. Am I missing something? Does this four-liner exist somewhere well-known already?

(Explanation in next post)

0

If you have a fediverse account, you can quote this note from your own instance. Search https://mastodon.social/users/mcc/statuses/114722210592125634 on your instance and quote it. (Note that quoting is not supported in Mastodon.)