Hacker Newsnew | past | comments | ask | show | jobs | submitlogin

You are correct. The type signature for push takes a mutable reference to self.

The code for a vector of i32s could look something like:

    impl Vec {
      pub fn push(&mut self, x:i32){
        // internal details
      }
    }


Many thanks. I think most of the confusion is to do with the comments, some of which the author has resolved so now my comment doesn't make much sense. But in the context of the original statement, thanks for your confirmation :)




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

Search: