macro_rules! selfref_match {
(
$selfref:expr, $field:ident {
$( $first:ident $(:: $rest:ident)* ($binding:tt) => $body:block )*
}
) => { ... };
}Expand description
Pattern-match on a field of a SelfRef<T>, projecting to SelfRef<VariantInner>
in each arm body.
Uses .get() to peek at the discriminant without consuming, then .map() to
project into the taken arm. The unreachable!() in each map closure is genuinely
unreachable because the matches! guard ensures only the correct variant reaches it.
Variants not listed are silently consumed and dropped.
§Example
ⓘ
selfref_match!(msg, payload {
MessagePayload::RequestMessage(r) => { /* r: SelfRef<RequestMessage> */ }
MessagePayload::ChannelMessage(c) => { /* c: SelfRef<ChannelMessage> */ }
})