Skip to content
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

const getter #31

Open
Luro02 opened this issue Sep 8, 2019 · 6 comments
Open

const getter #31

Luro02 opened this issue Sep 8, 2019 · 6 comments

Comments

@Luro02
Copy link

Luro02 commented Sep 8, 2019

Most, if not all getters (generic function parameters are currently unstable) can be const functions
https://rust-lang.github.io/rust-clippy/master/index.html#missing_const_for_fn

@Hoverbear
Copy link
Collaborator

Great idea. :)

@Hoverbear
Copy link
Collaborator

Just checked in, this is still unstable. :(

@Luro02
Copy link
Author

Luro02 commented Nov 17, 2019

This is stable

const fn get_value(&self) -> &String {
    &self.value
}

@Hoverbear
Copy link
Collaborator

Correct, but the generic case is not. :(

@SOF3
Copy link

SOF3 commented Jun 28, 2021

Any updates to this? It doesn't seem reasonable to put this on hold just because of a special case.
What about adding a feature gate or an attribute to enable const getters?

@Hoverbear
Copy link
Collaborator

Hoverbear commented Jun 29, 2021

I was working on a rewrite of this lib to better support features like this, but it's not done yet.

You're welcome to contribute a patch to add this feature, or as always, write the getters and setters yourself (as is probably best!).

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

No branches or pull requests

3 participants