Support for borrow across yield (self-referential generator)

Using Pin::new_unchecked is fine, assuming that you don't move the generator ever again.

Safe alternatives are:

Note that when using the latter method, you can call .as_mut() on the boxed generator to get a Pin<&mut T> to the generator.

3 Likes