While trying to implement traits with generic arguments and access the fields of those generic arguments, I've encountered an error message saying that the arguments in question do not contain such fields.
Here's some example code that exhibits the issue:
pub struct Settings {
pub time: String,
}
pub trait Foo {
fn get<T>(t: T);
}
struct Bar;
impl Foo for Bar {
fn get<Settings>(t: Settings) {
let x = t.time;
}
}
The error message given by the compiler is as follows:
error: no field `time` on type `Settings`
which makes little sense in the context. I expect that this is probably some misuse of generic traits on my part but the error message makes the question that.