Enable Address Sanitizer in Rust by setting RUSTFLAGS to -Zsanitizer=address and building with a nightly toolchain.
Enable Address Sanitizer (ASan) by setting the RUSTFLAGS environment variable to include -Zsanitizer=address before running cargo build.
export RUSTFLAGS="-Zsanitizer=address"
cargo build
This requires a nightly Rust toolchain. Run cargo +nightly build if your default toolchain is stable.
Address Sanitizer is a tool that finds memory bugs like reading or writing to the wrong place in your code. You turn it on by telling the Rust compiler to add special checks during the build process. It's like having a safety inspector watch your code run to catch dangerous mistakes before they crash your program.