Let binding with "|"

⚓ Rust    📅 2025-06-05    👤 surdeus    👁️ 4      

surdeus

Warning

This post was published 58 days ago. The information described in this article may have changed.

Info

This post is auto-generated from RSS feed The Rust Programming Language Forum - Latest topics. Source: Let binding with "|"

Why I can not write a code like this:

fn main() {
    let a = None;
    let b = Some(1);
    
    if let Some(c) = a | b {
        dbg!(c);
    }
}

I want to match the first one of a and b that can match successfully.

I think this is a natural idea for newbie.

8 posts - 4 participants

Read full topic

🏷️ rust_feed