What does borrow mean?

The more fundamental issue is that exclusive (&mut) borrows cannot survive use of the thing they borrowed from. And this applies transitively. Rather than try and write this all up from scratch, I'll refer you to these pointers to another thread where mental models for exclusive borrowing are walked through.

As for my vague definition, here's an example where bar involves no actual references, and there's not even an assignment from a to b (however, the API would allow one, and the API is the contract), and yet b is in some sense a borrow of s (or of the unsized str underlying s).

The actual analysis is pretty involved.

2 Likes