π¦ post a lot about rust and rust gamedev
βοΈ wrote https://sokoban.iolivia.me
π₯ blog at https://iolivia.me
π§΅ weekly #rustlang threads every Thursday - subscribe here https://forms.gle/Tcm7cAkLt4NF9ZCZ9
This year I'll try to stick to Thread Thursdays, which is every Thursday I'll post a thread about #rustlang fundamentals π¦
My goal is to help you learn 1% more Rust each Thursday, so follow me if you'd like to read them π¦
Here are some of the best threads so far π§΅π
So, to wrap it up, thank you everyone who read and enjoyed the threads, you are the best!
So, to wrap it up, thank you everyone who read and enjoyed the threads, you are the best!
Which makes the newsletter very difficult to grow, since my goal is to share this with as many people
Which makes the newsletter very difficult to grow, since my goal is to share this with as many people
Growing the newsletter is a whole different game, the bluesky community and traffic is pretty small, so it requires posting to reddit.
Growing the newsletter is a whole different game, the bluesky community and traffic is pretty small, so it requires posting to reddit.
I wrote 44 total threads, many of you read them, and liked them and almost 100 people subscribed to the newsletter!
I couldn't be more thankful for this.
But unfortunately, I will stop writing these for now.
Why? π
This year I'll try to stick to Thread Thursdays, which is every Thursday I'll post a thread about #rustlang fundamentals π¦
My goal is to help you learn 1% more Rust each Thursday, so follow me if you'd like to read them π¦
Here are some of the best threads so far π§΅π
I wrote 44 total threads, many of you read them, and liked them and almost 100 people subscribed to the newsletter!
I couldn't be more thankful for this.
But unfortunately, I will stop writing these for now.
Why? π
Hope it helped you learn 1% more Rust today, follow me for more threads like this and subscribe to receive these threads over email forms.gle/vY6zXE21Dkwa... π¦ π¦
Hope it helped you learn 1% more Rust today, follow me for more threads like this and subscribe to receive these threads over email forms.gle/vY6zXE21Dkwa... π¦ π¦
- Futures are lazy state machines
- Async provides concurrency, not necessarily parallelism
- Cooperative multitasking: tasks yield at .await points only
- Send = safe to move between threads
- Sync = safe to share references btwn threads
- Use async for I/O-bound, threads for CPU-bound
- Futures are lazy state machines
- Async provides concurrency, not necessarily parallelism
- Cooperative multitasking: tasks yield at .await points only
- Send = safe to move between threads
- Sync = safe to share references btwn threads
- Use async for I/O-bound, threads for CPU-bound
Async is perfect for I/O-bound operations where you're waiting for external resources, use async for concurrency with I/O. Use threads for CPU parallelism!
Async is perfect for I/O-bound operations where you're waiting for external resources, use async for concurrency with I/O. Use threads for CPU parallelism!
Async code needs a runtime to execute. The runtime manages the state machines, decides when to poll futures, and handles task scheduling. A main function in itself can be sync, with a runtime inside, or you could use #[tokio::main] to achieve the same with less boilerplate.
Async code needs a runtime to execute. The runtime manages the state machines, decides when to poll futures, and handles task scheduling. A main function in itself can be sync, with a runtime inside, or you could use #[tokio::main] to achieve the same with less boilerplate.
Sync trait is automatically implemented for types for which it is safe to share references between threads. A type cannot be Sync unless it is Send, which of course makes sense as you wouldn't be able to share a reference to an "unsafe" object.
Most types get automatic ...
Sync trait is automatically implemented for types for which it is safe to share references between threads. A type cannot be Sync unless it is Send, which of course makes sense as you wouldn't be able to share a reference to an "unsafe" object.
Most types get automatic ...
This won't work because Rc doesn't implement Send, which means BadTranscript doesn't implement Send, which means we actually can't move this value between threads and use it as an output of the async task.
This won't work because Rc doesn't implement Send, which means BadTranscript doesn't implement Send, which means we actually can't move this value between threads and use it as an output of the async task.
What if we wanted to return a transcript object like this?
This works!
What if we wanted to return a transcript object like this?
This works!
When you write async fn, Rust creates a Future - a value that may not be ready now but will be later. Futures are lazy and do nothing until you await them.
Behind the scenes, Rust compiles your async function into a state machine that can be paused at each await and resumed later.
When you write async fn, Rust creates a Future - a value that may not be ready now but will be later. Futures are lazy and do nothing until you await them.
Behind the scenes, Rust compiles your async function into a state machine that can be paused at each await and resumed later.
This is a perfect example to use async to handle all transcript requests concurrently and optimise resources. While we wait for that, we can do other work from another task.
This is a perfect example to use async to handle all transcript requests concurrently and optimise resources. While we wait for that, we can do other work from another task.
* call an API over the network to get the student's data
* do some CPU intensive work to calculate averages and totals based on that data
* generate a PDF in memory
* save PDF file
This means not all those ..
* call an API over the network to get the student's data
* do some CPU intensive work to calculate averages and totals based on that data
* generate a PDF in memory
* save PDF file
This means not all those ..
Let's see what happens when 3 students request transcripts using traditional blocking code. Not only is everything sequential, so each student needs to wait for all transcripts to finish before getting theirs, but also if we are on the main thread we'd be freezing the UI
Let's see what happens when 3 students request transcripts using traditional blocking code. Not only is everything sequential, so each student needs to wait for all transcripts to finish before getting theirs, but also if we are on the main thread we'd be freezing the UI
Send, Sync, Future, tokio, Pin, I'm sure you've heard a lot of intimidating terminology when it comes to async Rust, so this thread is about explaining the basics in a simple way.
We'll build a transcript generator to understand async/await, Futures
π§΅π
Send, Sync, Future, tokio, Pin, I'm sure you've heard a lot of intimidating terminology when it comes to async Rust, so this thread is about explaining the basics in a simple way.
We'll build a transcript generator to understand async/await, Futures
π§΅π
If you have a topic you'd like me to cover please suggest it in the replies π
If you have a topic you'd like me to cover please suggest it in the replies π
Hope it helped you learn 1% more Rust today, follow me for more threads like this and subscribe to receive these threads over email forms.gle/vY6zXE21Dkwa... π¦ π¦
Hope it helped you learn 1% more Rust today, follow me for more threads like this and subscribe to receive these threads over email forms.gle/vY6zXE21Dkwa... π¦ π¦
- Match on specific error variants to handle different cases
- Access error fields programmatically (like student_id, course_id)
- Make informed decisions based on the error type
- Match on specific error variants to handle different cases
- Access error fields programmatically (like student_id, course_id)
- Make informed decisions based on the error type