Closed
Description
Code
trait Trait<I> {
fn method(&self) {}
}
fn foo<T>(value: T) {
value.method()
}
Current output
error[E0599]: no method named `method` found for type parameter `T` in the current scope
--> src/lib.rs:6:11
|
5 | fn foo<T>(value: T) {
| - method `method` not found for this type parameter
6 | value.method()
| ^^^^^^ method not found in `T`
|
= help: items from traits can only be used if the type parameter is bounded by the trait
help: the following trait defines an item `method`, perhaps you need to restrict type parameter `T` with it:
|
5 | fn foo<T: Trait>(value: T) {
| +++++++
Desired output
error[E0599]: no method named `method` found for type parameter `T` in the current scope
--> src/lib.rs:6:11
|
5 | fn foo<T>(value: T) {
| - method `method` not found for this type parameter
6 | value.method()
| ^^^^^^ method not found in `T`
|
= help: items from traits can only be used if the type parameter is bounded by the trait
help: the following trait defines an item `method`, perhaps you need to restrict type parameter `T` with it:
|
5 | fn foo<T: Trait<_>>(value: T) {
| ++++++++++