Is reborrowing documented anywhere?

An important bit to understand when writing Rust code is that passing &'a mut around often inserts automatic reborrows, like &mut *x, which allows to “shorten” a unique lifetime and can easy be confused with variance.

Is this behavior documented anywhere?

Basically not. It’s mentioned offhand in the reference but not really documented well.

1 Like

There was a bit of an attempt as part of RFC 2364, which was postponed because the language team feels it would be better to do it after MIR borrowck, NLL, and Chalk are complete.

Old versions of the Rustonomicon had a brief description of reborrowing in the References chapter.


This topic was automatically closed 90 days after the last reply. New replies are no longer allowed.