Yes, that's a way to test a cast. There are other ways, even built in ones (like using try_into, etc). The problem I have isn't how to perform such tests, but how to enable such tests when the program is compiled in debug builds or in release builds that also use "-C overflow-checks". And how to disable such code when the code is compiled in release builds that lack the "-C overflow-checks". "disabling" and "enabling" in the sense like "#[cfg(not(debug_assertions))]" that can be used to disable code in release builds.