You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
mod banana {pubstructChaenomeles;pubtraitApple{fnpick(&self){}}implAppleforChaenomeles{}pubtraitPeach{fnpick(&self,a:&mut()){}}impl<Mango:Peach>PeachforBox<Mango>{}implPeachforChaenomeles{}}fnmain(){
banana::Chaenomeles.pick()}
error[[E0599]](https://doc.rust-lang.org/stable/error-index.html#E0599): no method named `pick` found for struct `Chaenomeles` in the current scope
[--> src/main.rs:17:25
](https://play.rust-lang.org/#) |
2 | pub struct Chaenomeles;
| ----------------------- method `pick` not found for this
...
10 | fn pick(&self, a: &mut ()) {}
| ---- the method is available for `Box<Chaenomeles>` here
...
17 | banana::Chaenomeles.pick()
| ^^^^ method not found in `Chaenomeles`
|
= help: items from traits can only be used if the trait is in scope
help: consider wrapping the receiver expression with the appropriate type
|
17 | Box::new(banana::Chaenomeles).pick()
| +++++++++ +
help: the following traits are implemented but not in scope; perhaps add a `use` for one of them:
|
1 | use crate::banana::Apple;
|
1 | use crate::banana::Peach;
|
Note that the message suggests wrapping the receiver expression in a Box::new even though it won't really help much unless the traits are imported. And if the trait was imported in the first place, the receiver type would've been fine either way.
The text was updated successfully, but these errors were encountered:
playground
Produces the output as such:
Note that the message suggests wrapping the receiver expression in a
Box::new
even though it won't really help much unless the traits are imported. And if the trait was imported in the first place, the receiver type would've been fine either way.The text was updated successfully, but these errors were encountered: