Hacker Newsnew | past | comments | ask | show | jobs | submitlogin

The compiler doesn't know anything about threads.

The compiler knows the Future doesn't implement the Send trait because MutexGuard is not Send and it crosses await points.

Then, tokio the aysnc runtime requires that futures that it runs are Send because it can move them to another thread.

This is how Rust safety works. The internals of std, tokio and other low level libraries are unsafe but they expose interfaces that are impossible to misuse.



Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: