An attempt was made to access an associated constant through either a generic type parameter or Self. This is not supported yet. An example causing this error is shown below:
#![allow(unused)]
fn main() {
trait Foo {
const BAR: f64;
}
struct MyStruct;
impl Foo for MyStruct {
const BAR: f64 = 0f64;
}
fn get_bar_bad<F: Foo>(t: F) -> f64 {
F::BAR
}
} Currently, the value of BAR for a particular type can only be accessed through a concrete type, as shown below:
#![allow(unused)]
fn main() {
trait Foo {
const BAR: f64;
}
struct MyStruct;
impl Foo for MyStruct {
const BAR: f64 = 0f64;
}
fn get_bar_good() -> f64 {
<MyStruct as Foo>::BAR
}
}
© 2010 The Rust Project Developers
Licensed under the Apache License, Version 2.0 or the MIT license, at your option.
https://doc.rust-lang.org/error_codes/E0329.html