rust-pretty-assertions icon indicating copy to clipboard operation
rust-pretty-assertions copied to clipboard

feat: Add opt-in via environment variable

Open dkellner opened this issue 6 months ago • 1 comments

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

dkellner avatar May 27 '25 07:05 dkellner

Do you have any objections to the approach in this PR? Let me know if there’s anything I can adjust.

dkellner avatar Jul 31 '25 14:07 dkellner