3 ms·
You can write it pretty compactly in Rust without introducing wildcards over non-boolean arguments. If you're extra paranoid you can write `true | false` instea
by orlp 3y ago
You can write it pretty compactly in Rust without introducing wildcards over non-boolean arguments. If you're extra paranoid you can write `true | false` instead of _ for those patterns in the below example
match (requires_approval, can_user_approve, item_status) {
(true, true, Available) => ReadWrite,
(true, false, Available) => ReadOnly,
(true, _, Inuse) => ReadOnly,
(true, _, NotAvailable) => Hidden,
(false, _, NotAvailable | Available | InUse) => Hidden,
}