Skip to content

Remove code inside debug_assert macro

Code inside debug_assert! is not called in release mode. In release mode all the debug_assert! is omitted so the code inside never runs.

https://doc.rust-lang.org/std/macro.debug_assert.html

I've moved all the code inside the debug_assert! call to outside and assign to a variable so the assert is done in development version but doesn't affects to the release version at all.

I've written an small example to show the problem with this macro:

https://play.rust-lang.org/?version=stable&mode=release&edition=2018&gist=e15847f96a2de188a46eabba4843f1f5

Merge request reports