Hacker News new | ask | show | jobs
by MichaelGG 3917 days ago
It's possible at compile time because you won't have the "MainThread" object available unless it's passed in to your other functions. And since you'll deny the traits for sending the object from the main thread to other threads, your methods can never be called.

And if you want it to be optional, like "if mainthread", then just accept an Option of MainThread.

In fact I see exactly this is proposed in the comments on the article: https://users.rust-lang.org/t/my-gamedever-wishlist-for-rust...

1 comments

Oh OK, that's cool. I don't think many languages could enforce that.