fork(1) download
  1. use struct_here::MyStruct;
  2. //use trait_here::MyTrait; // rustc suggest that, IntelliJ inserts automatically
  3.  
  4. mod struct_here {
  5. pub struct MyStruct;
  6.  
  7. impl MyStruct {}
  8. }
  9.  
  10. mod trait_here {
  11. use struct_here::MyStruct;
  12.  
  13. pub trait MyTrait {
  14. fn print_hello(&self);
  15. }
  16.  
  17. impl MyTrait for MyStruct {
  18. fn print_hello(&self) {
  19. println!("Hello, World!")
  20. }
  21. }
  22. }
  23.  
  24. fn main() {
  25. let instance = MyStruct {};
  26. instance.print_hello(); // <- situation: I'm writing this line of code
  27. }
  28.  
Compilation error #stdin compilation error #stdout 0s 0KB
stdin
Standard input is empty
compilation info
error: no method named `print_hello` found for type `struct_here::MyStruct` in the current scope
  --> prog.rs:26:14
   |
26 |     instance.print_hello(); // <- situation: I'm writing this line of code
   |              ^^^^^^^^^^^
   |
   = help: items from traits can only be used if the trait is in scope; the following trait is implemented but not in scope, perhaps add a `use` for it:
   = help: candidate #1: `use trait_here::MyTrait`

error: aborting due to previous error

stdout
Standard output is empty