rust-pretty-assertions
rust-pretty-assertions copied to clipboard
feat: Add opt-in via environment variable
When the new feature enable-via-env is enabled, pretty-assertions will only be active when the environment variable RUST_PRETTY_ASSERTIONS=1. Otherwise, the standard library assertion macros are used.
Opt-in is the most defensive approach. If you'd favor opt-out instead I'm happy to negate the current logic.
Disclaimer: My macro-fu is not strong - please review carefully :-).
Future work could add a note similar to RUST_BACKTRACE to educate users about pretty assertions in a codebase:
note: run with `RUST_BACKTRACE=1` environment variable to display a backtrace
note: run with `RUST_PRETTY_ASSERTIONS=1` environment variable to display a colored diff for failed assertions
Do you have any objections to the approach in this PR? Let me know if there’s anything I can adjust.