Note the todo!() -- this ensures that the code panics, causing it to not exit successfully, thus allowing the println's to show (rather than get captured).
The problem I run into is that if do_stuff() makes an unsafe C call and this call crashes the program, then all of my println output vanishes .Is there a way to somehow still get the println output in this case ?
Once you have gone "unsafe" and the code you run in there messes up the system, scribbling over memory, corrupting the stack, etc, anything can happen. Rust cannot help you. That is what "unsafe" is about.
It's time to breakout a debugger and debug that C code and/or your interface to it.
If you know that this is happening, you can use the nocapture flag on the test binary to have printing print directly to stdout. To use it, invoke cargo test like:
cargo test -- --nocapture
The extra -- is there so that --nocapture is passed to the actual test binary, not to cargo test.