jbaublitz / getset

Getters and Setters for Rust.
https://docs.rs/getset/
MIT License
340 stars 23 forks source link

const getter #31

Open Luro02 opened 5 years ago

Luro02 commented 5 years ago

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 commented 5 years ago

Great idea. :)

Hoverbear commented 4 years ago

Just checked in, this is still unstable. :(

Luro02 commented 4 years ago

This is stable

const fn get_value(&self) -> &String {
    &self.value
}
Hoverbear commented 4 years ago

Correct, but the generic case is not. :(

SOF3 commented 3 years ago

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 commented 3 years ago

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!).