News for hackers. Stuff that matters.
Re:Rust's Two Kinds of 'Assert' Make for Better Code by oefrha on Sunday November 24, 2024 @01:04AM (#42226200)
> The problem that I’ve just expressed ultimately occurs because languages like C force us to encode both kinds of assumption with a single assert statement: either all asserts are compiled in or none are.

It’s trivial to write a debug_assert macro in C, so no, you’re not forced to do that.

Re:Rust's Two Kinds of 'Assert' Make for Better Code by delaaxe on Sunday November 24, 2024 @01:19AM (#42226233)
It says so in the last paragraph
Re:Rust's Two Kinds of 'Assert' Make for Better Code by dmurray on Sunday November 24, 2024 @02:39AM (#42226541)
Right, this whole debug_assert thing is just a tiny bit of syntactic sugar. Everyone starts their C/C++ programs with a dozen lines of #define that wouldn't be necessary if only the authors in the 1980s had the foresight to design programming languages to fit the taste of 2020s programmers. This eliminates one of those lines.

Rust provides some remarkably rich features to help you reason about the assumptions, preconditions and postconditions your code has, but debug_assert isn't one of them.