What is Nostr?
Jonathan ‘theJPster’ Pallant /
npub1649…ytru
2024-02-17 16:29:47

Jonathan ‘theJPster’ Pallant on Nostr: Idle thought: what if in Rust you were able to write: pub nopanic fn foo() { … } ...

Idle thought: what if in Rust you were able to write:

pub nopanic fn foo() { … }

Functions marked nopanic can only perform operations that are themselves nopanic. A bit like const fns. If you really wanted you could make main a nopanic function. Unchecked arithmetic and slicing, and functions like unwrap, would all be forbidden inside a nopanic function.

You could also use the keyword “safe” instead of “nopanic”, leaving the default to be ?safe, or semi-safe (no UB, but could panic).
Author Public Key
npub1649fp6vel9jays9q5dvrqzu46uvz4k77c8uqjhgf9l98e8h0u2tqy5ytru