Closed
Description
This is something I have seen on users.rust-lang.org: https://users.rust-lang.org/t/implementing-fn-for-a-struct-thats-stored-in-vector/10814
A following code in my opinion should provide a hint to remove <Hello>
.
trait Trait {
fn do_stuff(&self);
}
struct Hello;
impl Hello {
fn method(&self) {}
}
impl<Hello> Trait for Vec<Hello> {
fn do_stuff(&self) {
self[0].method();
}
}
Currently it provides the following error which is non-ideal:
error[E0599]: no method named `method` found for type parameter `Hello` in the current scope
--> src/lib.rs:13:17
|
13 | self[0].method();
| ^^^^^^ method not found in `Hello`