News for hackers. Stuff that matters.
Re:How to Learn Modern Rust by outside1234 on Monday September 12, 2022 @01:56PM (#32814204)
My first piece of advice is to just start writing code.

If you are not specifically interested in super high performance systems level code, my second piece of advice would be to write code that avoids lifetime annotations until you get the basics of the borrow checker down.

For me, this meant writing a gRPC API with Rust using `tonic` with a `diesel` based persistence backend and observability with `tracing` and `opentelemetry`. This gives you a good survey of the basics and you'll learn about all of the core traits and language features in the process.

Re:How to Learn Modern Rust by bryanlarsen on Monday September 12, 2022 @02:04PM (#32814331)
Just start coding while avoiding lifetimes is great advice, but that's easier said than done. Rust makes some hard things simple and exposes hidden complexity in things you thought were simple.

Maybe I'd reframe it as "just start writing code, and use RC<> liberally to avoid lifetimes until you get a handle on them."

Also avoid async for that first project too.

Re:How to Learn Modern Rust by outside1234 on Monday September 12, 2022 @02:18PM (#32814542)
Yes - that's also good advice (using Arc/RC to liberally avoid ownership issues). I've personally had good experiences with async, but I can also see how that could be challenging depending on the background you are coming from.
Re:How to Learn Modern Rust by jcuenod on Monday September 12, 2022 @04:10PM (#32816186)
This is what I did. Still haven't figured out lifetimes or async, but I was impressed with how easily I managed to write something that works[1]...

[1] https://github.com/jcuenod/clickhouse-set-cover

Re:How to Learn Modern Rust by Matthias247 on Monday September 12, 2022 @09:08PM (#32819531)
Slightly off topic question/comment: You are running an async server, together with a blocking database client? That sounds more like a very tricky place ot get started. Are you dispatching all your database queries into an extra threadpool?
Re:How to Learn Modern Rust by throwaway239219 on Monday September 12, 2022 @10:11PM (#32819995)
Yes, as you have expected tokio has spawn_blocking which allows you to throw misbehaving code into a thread pool.

This started to disgust me so I jumped to sqlx.

Re:How to Learn Modern Rust by outside1234 on Tuesday September 13, 2022 @10:25AM (#32824674)
Yes - what throwaway said. Good suggestion as well to use sqlx instead.