Skip to content

Add Vec::resize_with#661

Open
jschillem wants to merge 2 commits into
rust-embedded:mainfrom
jschillem:vec-resize-with
Open

Add Vec::resize_with#661
jschillem wants to merge 2 commits into
rust-embedded:mainfrom
jschillem:vec-resize-with

Conversation

@jschillem
Copy link
Copy Markdown

Closes #648.

Adds Vec::resize_with, the closure-based counterpart to the existing resize method, in line with the std library resize_with method.

This method is valuable when you wish to resize the Vec and require some computation for each new element.

Changes

  • resize_with method added to Vec with documentation specifying when to use each of the resize functions.
  • Test coverage matching the resize method's coverage, as well as coverage for per-slot closure invocation, to test the invariant mentioned in the documentation.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[feature request] Vec::resize_with()

1 participant