Skip to content

Tracking issue for FromStr trait usage in const fn #59133

Open

Description

@elichai

Because Rust already have macros that evaluate on compile time to strings I think converting them to ints in a const fn is a very nice feature.

e.g. env!("SOMETHING").parse::<usize>().unwrap()


I opened this Issue as part of: #57563
Interested to hear if other people want this and if it's already exists as part of a different issue/RFC

Activity

  1. jonas-schievink commented on Nov 22, 2020

    @jonas-schievink
    Contributor

    Isn't this just #67792 / rust-lang/rfcs#2632?

  2. added
    C-tracking-issueCategory: An issue tracking the progress of sth. like the implementation of an RFC
    and removed
    C-feature-requestCategory: A feature request, i.e: not implemented / a PR.
    on Dec 4, 2023
  3. added a commit that references this issue on Mar 30, 2024
  4. Skgland commented on May 9, 2024

    @Skgland
    Contributor

    It looks like the const_int_from_str feature, gate-ing the constness of the {integer}::from_str_radix associated method, also points here. Would it be possible to have that stabilized as it (as far as I can see/tell) does not depend on const trait?, unlike the constness of the FromStr trait (impls) this is otherwise about.

    This would allow parsing ints at complie-time, e.g. from env!(), which I belive would help alot as that is the primary thing I find myself wanting to parse at compile-time.

  5. added 3 commits that reference this issue on Jul 26, 2024
  6. added a commit that references this issue on Jul 27, 2024
  7. added
    A-const-evalArea: Constant evaluation, covers all const contexts (static, const fn, ...)
    and removed on Dec 1, 2024
  8. added
    T-libsRelevant to the library team, which will review and decide on the PR/issue.
    and removed
    T-libs-api[DEPRECATED; DO NOT USE]
    on Aug 12, 2026
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-const-evalArea: Constant evaluation, covers all const contexts (static, const fn, ...)C-tracking-issueCategory: An issue tracking the progress of sth. like the implementation of an RFCT-libsRelevant to the library team, which will review and decide on the PR/issue.

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions