Skip to content

I wonder if all the methods of the crate could be made const #24

Description

@felix91gr

Hellu. First of all, thanks for the crate. It's freaking awesome.

So I was doing some exercises at exercism.org, as practice, and there was an exercise that used this crate. I realized that most of the functions it requires don't (or almost don't) need any runtime information to be computed:

  1. value_to_color_string can be solved with a const Hashmap<u32, &str>
  2. colors is basically a const Vec<ResistorColor>

So long story short, I realized that I couldn't make these things const because, among other things, enum-iterator itself's methods aren't const. So I came and tried to add constness for the methods, thinking of submitting that as a PR, but I ran into a wall in the language that took me to rust-lang/rust#101900.

I think the methods in the crate can't currently be made const (since they are Trait methods after all?), but I could be wrong.

Anywho. I'm 99% sure you've already delved into this, and that it's in some todo-list of your own. But perhaps it wasn't, and this helps somewhat.

Also this allows me to say thanks for the crate. It's a really cool crate. Thanks :D

Activity

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

    No labels
    No labels

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions