mercredi 26 octobre 2016

Is a tests submodule really reducing code bloat in Rust?

Section 5.2 Testing in the Rust Book says "The [tests] module allows us to group all of our tests together, and to also define helper functions if needed, that don't become a part of the rest of our crate. The cfg attribute only compiles our test code if we're currently trying to run the tests. This can save compile time, and also ensures that our tests are entirely left out of a normal build."

I presume functions marked as #[test] do not appear in release builds, even if they appear in a module that does, right? I'd expect it's just test helper functions that might waste space. And they could be hidden individually with #[cfg(test)], right?

Aucun commentaire:

Enregistrer un commentaire