4 ms·
In Rust, it is normally not possible or at least very difficult to create structs where one field references another, and if you were to create a future that bo
by aliceryhl 7y ago
In Rust, it is normally not possible or at least very difficult to create structs where one field references another, and if you were to create a future that borrows some field, awaits a future, and uses the borrowed field, the resulting future will need to have a field with a reference to another.
This is the challenge and async await lets you make this kind of self referential types without unsafe code.
- antisemiotic 7y agoThat's just the "Pin" type, which is heavily used in async code behind (and occasionally in front) the scenes, but is by no means restricted to it.
- Nemo157 7y agoIt's impossible to use the guarantees provided by the `Pin` type without `unsafe` code, except in `async fn`.