I've brought this example up before in this thread; nobody has really picked up the comparison: How do feel about type annotations on constants, statics and perhaps even functions return types. These are mandatory in Rust, yet they play no role in preventing undefined behavior.
I can bring up more examples: Exhaustive matches in Rust are mandatory, yet every match
could just as well come with an implicit panicking catch-all arm. Implementing a trait requires implementing all required methods, yet leaving out a required method could as well just mean that the method get's an always-panicking default implementation. (These examples so far all all things that e.g. Haskell does differently, yet I support the decision of Rust to be more strict.) Statements (like blocks or if
/match
/while
) that aren't terminated with a ;
are required to be of type ()
, even though that could as well be just a warning. If a type doesn't implement UnwindSafe
, that's a hard error, and you're required to manually insert an AssertUnwindSafe
in an appropriate place; even though UnwindSafe
is often called “basically just a lint” and it’s irrelevant for memory safety.