phobos icon indicating copy to clipboard operation
phobos copied to clipboard

Improve std.container.util.make with forwarding and clearer errors

Open shhreya13 opened this issue 8 months ago • 1 comments

Summary

This PR improves the make template in std.container.util.

Changes

  • Use std.algorithm.mutation.forward when passing constructor arguments to preserve move semantics and avoid unnecessary copies.
  • Add clearer compile-time diagnostics using static assert when a constructor cannot be called with the provided arguments.
  • Improve documentation explaining that make abstracts the difference between struct construction (T(args)) and class construction (new T(args)).
  • Add additional edge-case unit tests for empty containers and single-element input.

Motivation

These changes improve developer experience by providing clearer error messages and slightly improving argument handling while keeping existing behavior unchanged.

Related Issue

Closes #10972

shhreya13 avatar Mar 10 '26 15:03 shhreya13

Thanks for your pull request and interest in making D better, @shhreya13! We are looking forward to reviewing it, and you should be hearing from a maintainer soon. Please verify that your PR follows this checklist:

  • My PR is fully covered with tests (you can see the coverage diff by visiting the details link of the codecov check)
  • My PR is as minimal as possible (smaller, focused PRs are easier to review than big ones)
  • I have provided a detailed rationale explaining my changes
  • New or modified functions have Ddoc comments (with Params: and Returns:)

Please see CONTRIBUTING.md for more information.


If you have addressed all reviews or aren't sure how to proceed, don't hesitate to ping us with a simple comment.

Bugzilla references

Your PR doesn't reference any Bugzilla issue.

If your PR contains non-trivial changes, please reference a Bugzilla issue or create a manual changelog.

Testing this PR locally

If you don't have a local development environment setup, you can use Digger to test this PR:

dub run digger -- build "master + phobos#10973"

dlang-bot avatar Mar 10 '26 15:03 dlang-bot