Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Tracking Issue for [T; N]::resize(_with) (feature array_resize) #91615

Closed
3 tasks
scottmcm opened this issue Dec 7, 2021 · 1 comment
Closed
3 tasks

Tracking Issue for [T; N]::resize(_with) (feature array_resize) #91615

scottmcm opened this issue Dec 7, 2021 · 1 comment
Labels
C-tracking-issue Category: An issue tracking the progress of sth. like the implementation of an RFC T-libs-api Relevant to the library API team, which will review and decide on the PR/issue.

Comments

@scottmcm
Copy link
Member

scottmcm commented Dec 7, 2021

Feature gate: #![feature(array_resize)]

This is a tracking issue for the resize and resize_with methods on arrays.

Like Vec::resize(_with), these extend for a larger size or truncate for a shorter one. Unlike Vec, these return a new array (because obviously one can't change the size of a fixed-size array in-place).

Public API

impl<T, const N: usize> [T; N] {
    pub fn resize<const NEW_LEN: usize>(self, value: T) -> [T; NEW_LEN];
    pub fn resize_with<const NEW_LEN: usize>(self, mut f: impl FnMut() -> T) -> [T; NEW_LEN];
}

Steps / History

Unresolved Questions

  • None yet.
@scottmcm scottmcm added T-libs-api Relevant to the library API team, which will review and decide on the PR/issue. C-tracking-issue Category: An issue tracking the progress of sth. like the implementation of an RFC labels Dec 7, 2021
@briansmith
Copy link
Contributor

What is the motivation? concat! for arrays seems like an alternative that would allow the same with similar convenience and more generality.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
C-tracking-issue Category: An issue tracking the progress of sth. like the implementation of an RFC T-libs-api Relevant to the library API team, which will review and decide on the PR/issue.
Projects
None yet
Development

No branches or pull requests

2 participants