Join GitHub today
GitHub is home to over 31 million developers working together to host and review code, manage projects, and build software together.
Sign upTracking issue for Vec::resize_with and resize_default #41758
Comments
This comment has been minimized.
This comment has been minimized.
|
This would be an interesting addition for types which support In the future, just FYI, feature requests should go in the RFCs repository. |
This comment has been minimized.
This comment has been minimized.
|
Ah OK, noted. That's even for feature requests like this one that don't deserve an RFC? |
This comment has been minimized.
This comment has been minimized.
|
Yep! The general rule is either PR here or RFC elsewhere. Also, @joshlf would you mind renaming this issue to "Tracking issue for Vec::resize_default" ? And @nikomatsakis would you mind tagging it? |
joshlf
changed the title
Add Vec::resize_default method
Tracking issue for Vec::resize_default
May 15, 2017
This comment has been minimized.
This comment has been minimized.
|
Gotcha; thanks! |
bors
added a commit
that referenced
this issue
May 15, 2017
frewsxcv
added a commit
to frewsxcv/rust
that referenced
this issue
May 16, 2017
bors
added a commit
that referenced
this issue
May 16, 2017
Mark-Simulacrum
added
B-unstable
T-libs
labels
Jun 22, 2017
Mark-Simulacrum
added
the
C-tracking-issue
label
Jul 22, 2017
This comment has been minimized.
This comment has been minimized.
|
@rust-lang/libs Nominating for stabilization. The only potential concern is that we can generalize this to take a closure (see below). I don't know that it'd be all that useful, though, so I'm inclined to say that we shouldn't do so, and fn resize_with(&mut self, new_len: usize, f: F)
where F: FnMut() -> T |
Mark-Simulacrum
added
the
I-nominated
label
Jan 17, 2018
This comment has been minimized.
This comment has been minimized.
|
@Mark-Simulacrum I'd be willing to make a PR that adds |
This comment has been minimized.
This comment has been minimized.
|
I might lean more towards just having |
This comment has been minimized.
This comment has been minimized.
|
My concern is that |
This comment has been minimized.
This comment has been minimized.
|
Discoverability is pretty easily fixed by just having some documentation, though, right? I like the power of |
This comment has been minimized.
This comment has been minimized.
|
You'd just use |
This comment has been minimized.
This comment has been minimized.
|
The @rust-lang/libs team discussed this today and feel like |
alexcrichton
removed
the
I-nominated
label
Jan 29, 2018
This comment has been minimized.
This comment has been minimized.
|
I've submitted #49559 implementing |
djc
added a commit
to djc/rust
that referenced
this issue
Apr 1, 2018
djc
added a commit
to djc/rust
that referenced
this issue
Apr 2, 2018
djc
added a commit
to djc/rust
that referenced
this issue
Apr 3, 2018
kennytm
added a commit
to kennytm/rust
that referenced
this issue
Apr 4, 2018
bors
added a commit
that referenced
this issue
Apr 4, 2018
Centril
added a commit
to Centril/rust
that referenced
this issue
Dec 2, 2018
Centril
added a commit
to Centril/rust
that referenced
this issue
Dec 2, 2018
Centril
added a commit
to Centril/rust
that referenced
this issue
Dec 2, 2018
Centril
added a commit
to Centril/rust
that referenced
this issue
Dec 2, 2018
kennytm
added a commit
to kennytm/rust
that referenced
this issue
Dec 3, 2018
rfcbot
added
the
finished-final-comment-period
label
Dec 10, 2018
This comment has been minimized.
This comment has been minimized.
rfcbot
commented
Dec 10, 2018
|
The final comment period, with a disposition to merge, as per the review above, is now complete. |
rfcbot
removed
the
final-comment-period
label
Dec 10, 2018
scottmcm
added a commit
to scottmcm/rust
that referenced
this issue
Dec 20, 2018
Mark-Simulacrum
added a commit
to Mark-Simulacrum/rust
that referenced
this issue
Dec 21, 2018
pietroalbini
added a commit
to pietroalbini/rust
that referenced
this issue
Dec 21, 2018
pietroalbini
added a commit
to pietroalbini/rust
that referenced
this issue
Dec 21, 2018
Centril
added a commit
to Centril/rust
that referenced
this issue
Dec 22, 2018
kennytm
added a commit
to kennytm/rust
that referenced
this issue
Dec 22, 2018
kennytm
added a commit
to kennytm/rust
that referenced
this issue
Dec 22, 2018
kennytm
added a commit
to kennytm/rust
that referenced
this issue
Dec 22, 2018
bors
closed this
in
#57002
Dec 23, 2018
This comment has been minimized.
This comment has been minimized.
|
Reactivating because https://doc.rust-lang.org/nightly/std/vec/struct.Vec.html#method.resize_default still points here. Any thoughts on what should be done with |
scottmcm
reopened this
Dec 23, 2018
This comment has been minimized.
This comment has been minimized.
|
It’s the same as |
This comment has been minimized.
This comment has been minimized.
SoniEx2
commented
Dec 24, 2018
|
It's equivalent, but not the same. v.resize_default is more user-friendly! |
This comment has been minimized.
This comment has been minimized.
|
Is anyone using |
scottmcm
referenced this issue
Jan 16, 2019
Merged
Deprecate the unstable Vec::resize_default #57656
This comment has been minimized.
This comment has been minimized.
|
Isn't |
This comment has been minimized.
This comment has been minimized.
|
@Kerollmops And |
This comment has been minimized.
This comment has been minimized.
|
So, if we deprecate the |
joshlf commentedMay 4, 2017
Currently,
Vechas aresizemethod which takes anewparameter so that if the resize involves growing the vector, thenewparameter is cloned into each newly-created cell in the vector.Tmust implementClonein order for this method to be available.It would be useful to add a
resize_defaultmethod that instead requires thatT: Default, and callsT::default()to fill the newly-created cells. Not only would this be ergonomic, but for certain implementations ofT::default, it might allow the compiler to make better optimizations.