What is a good mental model of borrow checker?

A couple more earlier threads if you want to deep dive on the higher-ranked stuff

But the boldtype-in-textbook summary is still

  • &T is not a (single, concrete) type [1]
  • Generic type parameters must resolve to a single, concrete type

And the small textbook-infobox-example is

  • fn(&String) -> &String [2] does not satify a <I, O> Fn(&I) -> O [3] bound
    • Because O would have to match &String but that's not a type

  1. and there is no higher-ranked for<'any> &'any T type ↩︎

  2. aka for<'any> fn(&'any String) -> &'any String ↩︎

  3. aka <I, O> for<'any> Fn(&'any I) -> O ↩︎