The following `build.rs` script appears to have a concurrency issue. What is the reality of the situation?
Go & Rust interview question for Advanced practice.
Answer
No race condition occurs because Cargo provides a unique, separate OUTDIR for each crate's build script.
Explanation
While this code seems to present a race condition, Cargo's design prevents this specific issue. Each crate's build script is run with a unique OUTDIR path (e.g., target/debug/build/<crate-name-<hash/out). Therefore, two different crates with this build script would write to two completely different directories, avoiding a file conflict. The question highlights a good general principle (avoiding fixed output filenames), even if Cargo's architecture prevents it from being a bug in this case.