Re:Async Rust Is A Bad Language
by hedora on Friday September 08, 2023 @06:40PM
(#37440212)
What about the other way? There could be a trait that means “references have the same escape semantics as a stack frame”, perhaps called NotLeaky, and then a variant of tokio spawn could require NotLeaky, and return a non-‘static future. NotLeaky could be inferred in the same way as Send and Sync.
As a bonus, high-availability systems could require NotLeaky at the top of their event loop, precluding runtime memory leaks.
Edit: that wouldn’t work, since the future could be leaked by the caller… will read that reference.
Re:Async Rust Is A Bad Language
by SkiFire13 on Saturday September 09, 2023 @02:25AM
(#37442771)
This won't work because there's nothing forcing you to pass `NotLeak` types to APIs that respect them. In other words, implementing a trait can only add capabilities to a type, not restrict it.
As a bonus, high-availability systems could require NotLeaky at the top of their event loop, precluding runtime memory leaks.
Edit: that wouldn’t work, since the future could be leaked by the caller… will read that reference.