-
Notifications
You must be signed in to change notification settings - Fork 13.4k
impl Default
for array::IntoIter
#141574
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
base: master
Are you sure you want to change the base?
impl Default
for array::IntoIter
#141574
Conversation
@rust-lang/libs-api |
ACP is primarily to avoid unnecessary implementation effort, which is trivial here. I don't see any issue with going straight to FCP for this. Nominating for team discussion. |
It feels somewhat surprising to me that the default value of an array iterator would be empty instead of |
@rfcbot fcp merge |
Team member @dtolnay has proposed to merge this. The next step is review by the rest of the tagged team members: No concerns currently listed. Once a majority of reviewers approve (and at most 2 approvals are outstanding), this will enter its final comment period. If you spot a major issue that hasn't been raised at any point in this process, please speak up! See this document for info about what commands tagged team members can give me. |
This "feels" slightly odd to me. From what I can tell, this I think the thing that makes me feel uneasy about this is that this makes it so I'm not necessarily advocating for returning |
I mean... You can already do the following on stable: fn empty<T: Default + Copy, const N: usize>() -> std::array::IntoIter<T, N> {
let mut iter = [T::default(); N].into_iter();
iter.by_ref().for_each(|_| {});
iter
} |
Yeah I guess that renders my concern there moot. That was my poor attempt at articulating my feeling here. It doesn't get rid of my sense of this being a bit weird to me. I guess I'm just echoing @BoxyUwU here, but I'm not convinced that adding the impl at all is worth it. I don't feel strongly enough to render an objection though. |
Well sure, there is a bit of a difference here: for for Here But I can see arguments on both sides but I felt that an empty iterator was stronger. Ability to use |
cc #91583
my personal use of this feature comes from https://github.com/fee1-dead/w/blob/092db5df631ea515b688bae99c7f02eef12d7221/src/cont.rs#L154-L170
insta-stable, but I feel like this is small enough to not require an ACP (but a FCP per https://forge.rust-lang.org/libs/maintaining-std.html#when-theres-new-trait-impls)? feel free to correct me if I am wrong.