Summary
Avoid cloning the emitted build file path in src/runner.rs::handle_build when args.emit is present by representing the path as a borrowed value in that branch and as an owned value for the temporary-file case. Use std::borrow::Cow to express the mixed ownership.
Background
Flagged during code review on PR #82 as a small clean-up/micro-optimisation. This removes an unnecessary allocation and clarifies ownership semantics, while preserving existing behaviour and logs.
Scope
- Change handle_build to bind build_path as Cow.
- Borrow the path in the Some(args.emit) branch; own the temp-file path in the None branch.
- Update the run_ninja call site to pass build_path.as_ref().
- Add the necessary import for std::borrow::Cow.
- Do not change run_ninja’s signature or behaviour.
Acceptance criteria
- No clone of the emitted path in the Some(args.emit) branch.
- Build, lint and tests pass (e.g., make lint, make test).
- No borrow checker/lifetime regressions.
- Repository linting standards are upheld (no blanket allows; docs intact).
References
Summary
Avoid cloning the emitted build file path in src/runner.rs::handle_build when args.emit is present by representing the path as a borrowed value in that branch and as an owned value for the temporary-file case. Use std::borrow::Cow to express the mixed ownership.
Background
Flagged during code review on PR #82 as a small clean-up/micro-optimisation. This removes an unnecessary allocation and clarifies ownership semantics, while preserving existing behaviour and logs.
Scope
Acceptance criteria
References