-3

How do I import a mod into rust?

1) I have a file with these contents:

this_is_stupid.rs

pub mod fix_me {

    use crate::InputData;

    pub trait Wow {
        fn findMe(&self);
    }


    //impl  InputData {
    impl Wow for InputData {

        fn findMe(&self) {
            print!("Really dudes we are working?");
        }
    } //end impl 
} // mod 

In my main I have this:

   pub mod this_is_stupid;
   use crate::this_is_stupid::fix_me;
   pub struct InputData {}
   fn main() {
        let input_data: InputData{};
        fix_me::Wow::findMe();
    }

Here is my error:

error[E0061]: this function takes 1 parameter but 0 parameters were supplied                                                                                          
  --> src/main.rs:85:9                                                                                                                                                
   |                                                                                                                                                                  
85 |         fix_me::Wow::findMe();                                                                                                                                   
   |         ^^^^^^^^^^^^^^^^^^^^^ expected 1 parameter                                                                                                               
   |                                                                                                                                                                  
  ::: src/this_is_stupid.rs:12:9                                                                                                                                      
   |                                                                                                                                                                  
12 |         fn findMe(&self);                                                                                                                                        
   |         ----------------- defined here   
Tampa
  • 75,446
  • 119
  • 278
  • 425
  • 1
    Your code is not valid rust syntax, e.g. `pub struct InputData{};` is not valid. Please fix that and format your code according to the rustfmt guidelines, e.g. by using [the playground](https://play.rust-lang.org) – hellow Jan 18 '19 at 07:29

1 Answers1

2

It seems like you imported the mod but called the function wrong.

You can call it in two different ways:

  1. fix_me::Wow::findMe(&input_data);
  2. input_data.findMe();
Akiner Alkan
  • 6,145
  • 3
  • 32
  • 68