-
Notifications
You must be signed in to change notification settings - Fork 2
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
Can this crate work with Associated Constants ? #1
Comments
I'm not sure this can be supported. But if there is some way to get this working I'd love to add it. Both generics and Minimal example: trait Foo {
const BAR: &'static str;
}
fn takes_foo<T: Foo>() {
const TEST: &str = T::BAR;
} |
@DontBreakAlex I ran into the same. This would save users of my crate (zvariant and zbus in turn) so many allocations as I can then turn one the main/central trait to use associated constants. |
@rossmacarthur This can be fixed by using inline |
After several attempts to implement this using inline |
Just for the record here, I went for a completely different approach and no longer require concatenating strings in const context. |
I attempted this when const inlining was first introduced, but was unable to get things to work. I think its mainly due to this section in the RFC: https://rust-lang.github.io/rfcs/2920-inline-const.html#generic-parameters It also has a pretty good explanation why it isn't supported yet. |
Currently it produces this error when attempting to use Associated Constants:
I'm not sure what is going on, can this be supported ?
The text was updated successfully, but these errors were encountered: