A function that takes &mut but returns a & borrow

No. It doesn't "realize" that because it is not true.

Unsafe code relies on this guarantee (ie. all borrows upholding a mutable borrow with the same lifetime), and there doesn't seem to be any way to express the same pattern without the current behavior.

Read more here.

1 Like