Discussion
Loading...

Discussion

  • About
  • Code of conduct
  • Privacy
  • Users
  • Instances
  • About Bonfire
Jan :rust: :ferris:
@janriemer@floss.social  ·  activity timestamp 3 weeks ago

First, the async runtime:

My advice: If you're new to async Rust, start with a single-threaded-by-default runtime like smol:
https://docs.rs/smol/latest/smol/

Tokio's multi-threading by default and its frequent recommendation (especially to newcomers) is, IMHO, one of the biggest mistakes the Rust community has made!

Smol has everything you commonly need:
- channel
- Stream adapters
- etc.

3/?

  • Copy link
  • Flag this post
  • Block
Jan :rust: :ferris:
@janriemer@floss.social replied  ·  activity timestamp 3 weeks ago

Second: Pinning helpers!

When doing async #Rust, there will be a point, where you'll get the ominous "Doesn't implement Unpin" error and "You need to pin your value".

First, learn about Pinning:
https://doc.rust-lang.org/std/pin/

Like, really learn and understand it:
https://fasterthanli.me/articles/pin-and-suffering

And then use smol's pin! macro and the pin_project crate:
https://docs.rs/pin-project/latest/pin_project/

I might continue this thread with more insights I gain during this little project - stay tuned! 🙂

4/4?

#RustLang#AsyncRust

  • Copy link
  • Flag this comment
  • Block
Log in

bonfire.cafe

A space for Bonfire maintainers and contributors to communicate

bonfire.cafe: About · Code of conduct · Privacy · Users · Instances
Bonfire social · 1.0.0-rc.2.21 no JS en
Automatic federation enabled
  • Explore
  • About
  • Members
  • Code of Conduct
Home
Login