#letelse

Ihor Kalnytskyiihor@fosstodon.org
2025-12-15

TIL Rust has the `let-else` construct! I used to get annoyed at how verbose it was to unpack an Option/Result just to log an error and leave early if it was None/Err. Turns out there's a neat syntax for that now.

#rust #syntax #letelse

let Some(network) = network else {
    error!("MAVLink cannot be enabled because the network is not initialized.");
    return;
};

Client Info

Server: https://mastodon.social
Version: 2025.07
Repository: https://github.com/cyevgeniy/lmst