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

Async rust isn't pretty.

If you are using async rust, and want to borrow data, use an Arc<T>.

In fact, if you ever use tokio::spawn, you will have to use Arc<T> anyway because it requires 'static lifetime.



True about 'static. Sometimes I think I need an IDE shortcut for `Send + Sync + 'static`.

Like `if err != nil`, you know :))


The trait_alias[1] nightly feature might be what you want :)

It was dormant for a long time, but it seems like it might be getting some love towards stabilization (or outright removal, I guess) at some point in the medium future.

[1]: https://doc.rust-lang.org/beta/unstable-book/language-featur...


You can also use Box::leak to obtain 'static references to stuff that lives till the end of the program.




Consider applying for YC's Winter 2027 batch! Applications are open till November 2.

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

Search: