1. 12
  1.  

  2. 1

    Rust lets you borrow stuff, just remember to always use the & and you’ll be fine.

    This is what I had the hardest time coming to terms with when trying to break my code down into functions when I was beginning to learn Rust. But instead of thinking of the ampersand as the “address of” operator, remembering that it is the “borrow” operator makes a lot more sense. You are just giving that data to something else for it’s execution and then it’s your (caller) data again.

    1. 2

      In the article this quote is clearly sarcastic, but this isn’t great advice in every case, in case you’re just skimming comments here. If you find yourself calling clone() on an argument passed in, you maybe should have required ownership on it instead of asking for a reference to it. This also communicates the internal semantics more clearly to callers.