Closed GKFX closed 3 months ago
This looks great, though I think it's a requirement to make it the default to be able to tell how the values differ... Can we use format!()
in the message or something along those lines?
(or does the assert macro print that already?)
There's no way to print such thing on const
context AFAIK
I haven't been able to play with this yet but maybe we can abuse slice indexing to at least print the differences between actual and expected? E.g for [0u8][X - Y]
or something like that which would panic if X was different to Y, and I would expect the compiler to print the bad index?
oh that's so hacky... I love it!
Using slice indexing works. I've put the string as the expression in the array rather than 0u8
so it's visible.
This commit emits layout tests as compile-time assertions, rather than as unit tests. This allows them to be run in situations where running unit tests is unfeasible, i.e. cross-compiled code and nostd targets.
Fixes #2786. @ojeda - I noticed you tagged the feature request for Rust-for-Linux.