title: Right way to have Function pointers in struct
body: <p>I'm trying to make a struct that has a mutable function pointer. I have it setup so that the function pointer is initialized to a particular function, but rust doesn't recognize the pointer when i try to use it. </p>
  
  <p>i get </p>
  
  <pre><code>hello.rs:24:14: 24:22 error: no method named `get_func` found for type `&amp;Container` in the current scope
  hello.rs:24         self.get_func(self, key)
                           ^~~~~~~~
  </code></pre>
  
  <p>here's my code</p>
  
  <pre><code>use std::collections::HashMap;
  
  struct Container {
      field: HashMap&lt;String, i32&gt;,
      get_func: fn(&amp;Container, &amp;str) -&gt; i32
  }
  
  fn regular_get(obj: &amp;Container, key: &amp;str) -&gt; i32 {
      obj.field[key]
  }
  
  impl Container {
      fn new(val: HashMap&lt;String, i32&gt;) -&gt; Container {
          Container {
              field: val,
              get_func: regular_get
          }
      }
  
      fn get(&amp;self, key: &amp;str) -&gt; i32 {
          self.get_func(self, key)
      }
  }
  
  fn main() {
      let mut c:HashMap&lt;String, i32&gt; = HashMap::new();
      c.insert("dog".to_string(), 123);
      let s = Container::new(c);
      println!("{} {}", 123, s.get("dog"));
  }
  </code></pre>