Let binding with "|"

⚓ rust    📅 2025-06-05    👤 surdeus    👁️ 2      

surdeus

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