Skip to content

Tracking Issue for NonZero*::count_ones #120287

Closed

Description

@WaffleLapkin

Feature gate: #![feature(non_zero_count_ones)]

This is a tracking issue for NonZero*::count_ones family of methods.

Public API

// core::num

impl NonZero* {
    pub fn count_ones(self) -> NonZeroU32;
}

Steps / History

Unresolved Questions

  • None yet.

Footnotes

  1. https://std-dev-guide.rust-lang.org/feature-lifecycle/stabilization.html ↩

Activity

  1. added
    T-libs-api[DEPRECATED; DO NOT USE]
    C-tracking-issueCategory: An issue tracking the progress of sth. like the implementation of an RFC
    on Jan 24, 2024
  2. tyilo commented on Nov 8, 2024

    @tyilo
    Contributor

    Anything holding this back from getting stabilized?

  3. WaffleLapkin commented on Nov 9, 2024

    @WaffleLapkin
    MemberAuthor

    @tyilo nothing that I'm aware of.

    @rust-lang/libs-api I would like to propose this feature for stabilization. This feature adds a very straightforward function:

    impl NonZero* {
        pub fn count_ones(self) -> NonZeroU32;
    }

    The benefit here, as opposed to writing .get().count_ones(), is that NonZero::count_ones returns NonZeroU32 and not u32 (a non-zero number must have at least one bit set!). The implementation is very simple and hasn't changed since the original addition in 1.77.

  4. tyilo commented on Nov 9, 2024

    @tyilo
    Contributor

    I understand that this returns NonZeroU32 because <integer>::count_ones returns u32.

    But why u32 and not u8 or u16?

    u8 would work for all current primitive integers, but not for the potential u256 and i256.
    u16 would first fail when introducing u65536 and i65536 which seems unlikely to ever happen.

  5. WaffleLapkin commented on Nov 9, 2024

    @WaffleLapkin
    MemberAuthor

    @tyilo it's not necessarily that we have to use 32 bits, and more so that u32 is the default integer type for when you don't really care about the width. you may notice that it's not only count_ones, but a lot of things like BITS, ilog, {leading,trailing}_{zeros,ones}, etc.

  6. Amanieu commented on Nov 25, 2024

    @Amanieu
    Member

    @rfcbot fcp merge

  7. rfcbot commented on Nov 25, 2024

    @rfcbot

    Team member @Amanieu 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.

  8. added
    proposed-final-comment-periodProposed to merge/close by relevant subteam, see T-<team> label. Will enter FCP once signed off.
    on Nov 25, 2024
  9. removed
    proposed-final-comment-periodProposed to merge/close by relevant subteam, see T-<team> label. Will enter FCP once signed off.
    on Nov 25, 2024
  10. added
    disposition-mergeThis issue / PR is in PFCP or FCP with a disposition to merge it.
    on Nov 25, 2024
  11. added
    final-comment-periodIn the final comment period and will be merged soon unless new substantive objections are raised.
    on Jan 27, 2025
  12. rfcbot commented on Jan 27, 2025

    @rfcbot

    🔔 This is now entering its final comment period, as per the review above. 🔔

  13. added and removed
    final-comment-periodIn the final comment period and will be merged soon unless new substantive objections are raised.
    on Feb 6, 2025
  14. rfcbot commented on Feb 6, 2025

    @rfcbot

    The final comment period, with a disposition to merge, as per the review above, is now complete.

    As the automated representative of the governance process, I would like to thank the author for their work and everyone else who contributed.

    This will be merged soon.

  15. added 2 commits that reference this issue on Feb 11, 2025
  16. added a commit that references this issue on Feb 11, 2025
  17. added 2 commits that reference this issue on Mar 11, 2025
  18. cuviper commented on Mar 21, 2025

    @cuviper
    Member

    Stabilized in #136663

  19. added this to the 1.86.0 milestone on Mar 21, 2025
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

    C-tracking-issueCategory: An issue tracking the progress of sth. like the implementation of an RFCT-libs-api[DEPRECATED; DO NOT USE]disposition-mergeThis issue / PR is in PFCP or FCP with a disposition to merge it.finished-final-comment-periodThe final comment period is finished for this PR / Issue.

    Type

    No type

    Projects

    No projects

      Milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions