Elektrine lite

โ† Feed

@bugaevc@floss.social

Post #2227720

2025-11-19 07:37 UTC

@Mara@hachyderm.io yes please! ๐Ÿ’ฏ I had a design where the || and && operators were overloadable, and there, res.unwrap() turned into res || panic!() and res.unwrap_or(default_value) into res || default_value and res.unwrap_or_else(callback) into res || callback() But if you're not doing that, renaming the methods would be great.

Replies (2)

  • @Mara@hachyderm.io 2025-11-19 07:45

    @bugaevc@floss.social How would `res || panic!("oh no")` show the Err value in the panic message? res.unwrap() and res.expect("oh no") both show the Err value.

    Open ##2227721

  • @oli@hachyderm.io 2025-11-19 08:06

    @bugaevc@floss.social @Mara@hachyderm.io So... || is just a postfix closure with no `.`, conditionally invoked on the lhs producing a failure value (right now only `false` is supported ๐Ÿ˜€)

    Open ##2227728