Skip to content

Tracking issue for by-value array iterator (feature array_value_iter) #65798

Closed

Description

@LukasKalbertodt

This is a tracking issue for core::array::IntoIter. Implemented in #62959.

Blocked by:

Unresolved questions:

Activity

  1. rustbot commented on Oct 25, 2019

    @rustbot
  2. added
    B-unstableBlocker: Implemented in the nightly compiler and unstable.
    C-tracking-issueCategory: An issue tracking the progress of sth. like the implementation of an RFC
    T-libs-api[DEPRECATED; DO NOT USE]
    on Oct 25, 2019
  3. CryZe commented on Oct 25, 2019

    @CryZe
    Contributor

    For an IntoIterator impl we should probably issue warnings as soon as possible (not just via clippy).

  4. LukasKalbertodt commented on Nov 4, 2019

    @LukasKalbertodt
    ContributorAuthor

    Can we even stabilize this before stabilizing const generics? No, right? Because the public API clearly contains parts of const generics. Or is it possible to stabilize because the only way programmers can interact with the type is not dependent on const generics?

    Also: could we add the IntoIterator impl for arrays without stabilizing this (the std::array::IntoIter type)? As the PR showed, people can use the iterator without the #![feature(array_value_iter)]. The unstable feature is just required to name the type. But it also seems strange to have a (necessarily) stable impl that uses an unstable type.

  5. SimonSapin commented on Nov 4, 2019

    @SimonSapin
    Contributor

    Right, unlike impls like for example impl<T: Eq, const N: usize> Eq for [T; N] where [T; N]: LengthAtMost32 {} which we could revert to 32 separate macro-generated impls, array::IntoIter is a generic type that has a const paramater which couldn’t be represented if we ever came to remove const generics from the language.

  6. LukasKalbertodt commented on Nov 8, 2019

    @LukasKalbertodt
    ContributorAuthor

    @SimonSapin Just to be sure I understand you correctly, what is your answer to this question?

    Could we add the IntoIterator impl for arrays without stabilizing std::array::IntoIter?

    Using the impl without #![feature(array_value_iter)] works, but it seems strange to me that we can "use" an unstable type as long as we don't name it. On the other hand, since the IntoIterator impl is bound by LengthAtMost32, if const generics were to be removed, we could simply add 32 different iterator types to the standard library. Right? So in theory we could add the impl? Is there some precedence to this?

  7. SimonSapin commented on Mar 19, 2020

    @SimonSapin
    Contributor

    My previous comment was saying that we cannot stabilize a struct IntoIter<const N: usize, T> {…} type without definitely relying on const generics, because the const parameter is visible in that signature. Adding a where [T; N]: LengthAtMost32 bound is not enough, unlike for trait impls.


    Additionally, cross-posting from #65819 (comment):

    With my Libs team hat on: I’d be uncomfortable stabilizing a method that returns an unstable type. Yes this does mean blocking array by-value iterators on const generics. (Or stabilizing an array trait and a const-generics-free iterator type.)

    F-const_generics `#![feature(const_generics)]` shows active work. It’ll come. In the meantime, as @mpdn mentioned the arrayvec crate provides an alternative.

  8. added
    I-libs-radarLibs issues that are tracked on the team's radar.
    A-slice-vecArea: `[T]` and `Vec<T>`
    on Jul 29, 2020
  9. Plecra commented on Aug 7, 2020

    @Plecra

    The DoubleEndedIterator implementation seems counter-intuitive to me. I was under the impression that the trait was typically implemented where it could be done in a zero-cost way, like how slices are required to track their length anyway. Many of the std iterators could implement more of the iterator traits if they just tracked more state.

    Is the DoubleEndedIterator implementation particularly urgent? Maybe it doesn't need to be stabilized with the main Iterator implementation...

  10. cuviper commented on Aug 7, 2020

    @cuviper
    Member

    I think it would be strange if array::IntoIter didn't implement DoubleEndedIterator, as it would be deficient compared to slice and Vec iterators. There are plenty of standard iterators that already track extra state to support reversing -- e.g. FlatMap would be a lot simpler if it didn't need that.

  11. KodrAus commented on Nov 26, 2020

    @KodrAus
    Contributor

    Have we done any crater runs recently on where the lint has landed us? If not, would anybody be interested in opening up an experimental PR to check?

  12. LukasKalbertodt commented on Nov 26, 2020

    @LukasKalbertodt
    ContributorAuthor

    The last crater run AFAIK was this one. The problem is that crater doesn't seem to update the Cargo.lock (also see this comment. This means there are still a ton of non-root regressions that can be fixed by a simple cargo update. Also take a look at my comment here, where I estimate that roughly 4000 of the 4771 regressions crater found would be trivially fixable.

    It would be really beneficial if we could update (or remove) the Cargo.lock on the crater machines, but I'm not sure how easy that would be.

    If you want to run crater again, I can just update my PR again. Or are you mentioning "experimental PR" to reduce noise on the main PR?

  13. SimonSapin commented on Dec 28, 2020

    @SimonSapin
    Contributor

    This is unblocked! #79135 has landed. What remains here is to decide how should one obtain an array::IntoIter value:

  14. SimonSapin commented on Dec 29, 2020

    @SimonSapin
    Contributor

    @scottmcm weighed in on Zulip: https://rust-lang.zulipchat.com/#narrow/stream/219381-t-libs/topic/array.20by-value.20iterator.20stabilization/near/221116093

    I like stabilizing the IntoIter::new method. That's a totally reasonable API to exist (even if eventually deprecated later) and conveniently is over on a type that people will rarely look at once the IntoIterator finally happens. Needing the import is unfortunate, but I think the goal here is to unblock people which it does fine, and it'd be nice to avoid a vestigial method on the array type (at which people will actually commonly look). Especially to avoid any confusion about "Why isn't there iter_owned on a Vec? Can I not get an owning iterator to the items in a vector?"

    Sounds good to me. I’ve submitted a stabilization PR and requested FCP: #80470

  15. SimonSapin commented on Jan 31, 2021

    @SimonSapin
    Contributor

    Stabilized in 1.51.0 by #80470.

    The IntoInterator impl is tracked separately at #65819.

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    A-iteratorsArea: IteratorsA-slice-vecArea: `[T]` and `Vec<T>`B-unstableBlocker: Implemented in the nightly compiler and unstable.C-tracking-issueCategory: An issue tracking the progress of sth. like the implementation of an RFCI-libs-radarLibs issues that are tracked on the team's radar.T-libs-api[DEPRECATED; DO NOT USE]

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions