Hacker News new | past | comments | ask | show | jobs | submit login

You can, e.g.

  struct Foo;

  impl Foo {
      fn bar(&self) {}
  }

  fn main() {
      let x = Foo;
      Foo::bar(&x);
  }
What you may be encountering is you can't pass a `Foo` when a `&Foo` is expected (why I needed to write &x), because the types differ. Calls with method syntax don't see this because they automatically borrow the receiver if necessary, but explicit function calls do not do this sort of borrowing and so the types need to line up right.



Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: