Calling an async fn runs none of its body. The call only creates a value that implements Future, and the body advances to the next .await only when someone calls that value’s poll. When it cannot advance, poll leaves behind a Waker so the task can be woken later and returns Pending right away. That is what lets an executor like tokio poll many tasks in turn on a few threads. The flip side is that if poll holds its thread for a long time, every other task waiting on that thread falls behind. On a runtime with two workers, running four 100ms std::thread::sleep jobs inside tasks made a task that should wake every 10ms run about 200ms late.

I wanted to know exactly what slows down when an async handler in an API server calls a synchronous DB driver or does file I/O, so I worked through it in order, from the point where a Future becomes a state machine up to the tokio scheduler.

I compiled and ran every example below with rustc 1.94.1, edition 2021, on aarch64-apple-darwin (Apple M4 Pro, 12 cores, macOS 15.1). The tokio examples were built with --release in a cargo project that depends on tokio 1.54.1. While the tokio experiments ran, other work kept this machine’s load average at 82–91. The timings reflect that load.

Calling an async fn

Calling an async fn only creates a Future value; the body runs when it is polledfetch_user(7)callimpl Future<Output = String>the body has not run yetdropped.await · pollgone, body never ranthe body runs
async fn fetch_user(id: u64) -> String {
    println!("fetch_user({id}) running");
    format!("user-{id}")
}

fn main() {
    fetch_user(7);
    println!("called fetch_user");
}
warning: unused implementer of `Future` that must be used
 --> lazy.rs:7:5
  |
7 |     fetch_user(7);
  |     ^^^^^^^^^^^^^
  |
  = note: futures do nothing unless you `.await` or poll them
  = note: `#[warn(unused_must_use)]` (part of `#[warn(unused)]`) on by default
called fetch_user

fetch_user(7) was called, yet fetch_user(7) running never printed. As the warning’s note says, a future does nothing until you .await it or poll it. The std::future::Future docs say the same: futures alone are inert, and they have to be actively polled for the computation to make progress.

poll and Waker

A future that returns Pending keeps the Waker, and the executor polls again when wake is calledexecutorhandlerDelaytimer threadpoll #1pollstart timerkeep Waker clonePendingPendingpark (sleep)wake() → unparkpoll #2pollReady(())run to the next .await

The Future trait has one method, poll. It returns Poll::Ready(value) when the work is finished and Poll::Pending when it is not. The Future::poll docs explain that a future that is not ready stores a clone of the Waker from the current Context when it returns Pending, and wakes that Waker once it can make progress. The woken task then polls the future again.

I built that flow with only the standard library. block_on polls the future and, on Pending, parks the thread. The Waker unparks that thread when wake is called. Delay starts a timer thread the first time it is polled and wakes the stored Waker when the time is up.

use std::future::Future;
use std::pin::{pin, Pin};
use std::sync::{Arc, Mutex};
use std::task::{Context, Poll, Wake, Waker};
use std::thread::{self, Thread};
use std::time::Duration;

struct ThreadWaker(Thread);

impl Wake for ThreadWaker {
    fn wake(self: Arc<Self>) {
        println!("    [waker] wake -> unpark executor");
        self.0.unpark();
    }
}

fn block_on<F: Future>(fut: F) -> F::Output {
    let mut fut = pin!(fut);
    let waker = Waker::from(Arc::new(ThreadWaker(thread::current())));
    let mut cx = Context::from_waker(&waker);
    for count in 1.. {
        println!("[executor] poll #{count}");
        if let Poll::Ready(output) = fut.as_mut().poll(&mut cx) {
            return output;
        }
        println!("[executor] Pending -> park");
        thread::park();
    }
    unreachable!()
}

struct Delay {
    ms: u64,
    state: Arc<Mutex<DelayState>>,
}

struct DelayState {
    started: bool,
    done: bool,
    waker: Option<Waker>,
}

fn delay(ms: u64) -> Delay {
    let state = DelayState { started: false, done: false, waker: None };
    Delay { ms, state: Arc::new(Mutex::new(state)) }
}

impl Future for Delay {
    type Output = ();

    fn poll(self: Pin<&mut Self>, cx: &mut Context<'_>) -> Poll<()> {
        let mut state = self.state.lock().unwrap();
        if state.done {
            return Poll::Ready(());
        }
        state.waker = Some(cx.waker().clone());
        if !state.started {
            state.started = true;
            let (ms, shared) = (self.ms, Arc::clone(&self.state));
            thread::spawn(move || {
                thread::sleep(Duration::from_millis(ms));
                let mut state = shared.lock().unwrap();
                state.done = true;
                state.waker.take().unwrap().wake();
            });
        }
        Poll::Pending
    }
}

async fn handler() -> &'static str {
    println!("  [handler] start");
    delay(50).await;
    println!("  [handler] after first delay");
    delay(30).await;
    println!("  [handler] after second delay");
    "done"
}

fn main() {
    let output = block_on(handler());
    println!("output = {output}");
}
[executor] poll #1
  [handler] start
[executor] Pending -> park
    [waker] wake -> unpark executor
[executor] poll #2
  [handler] after first delay
[executor] Pending -> park
    [waker] wake -> unpark executor
[executor] poll #3
  [handler] after second delay
output = done

handler finished in three polls. The first poll printed start and returned Pending at the first delay(50).await. The second poll picked up on the line after the first .await. In between, the executor slept for 50ms and then 30ms and did not burn CPU on repeated polls. The Waker told it when to poll again.

An async fn written out by hand as a state machine

The handler future is a state machine with one state per await pointStartbefore the body startsWaitFirst(Delay)waiting at delay(50).awaitWaitSecond(Delay)waiting at delay(30).awaitDoneafter returning "done"poll #1poll #2 · Readypoll #3 · ReadyPendingPending

The second poll resumed in the middle because the value handler returned remembers how far it got. The compiler turns an async fn body into a state machine with one state per .await point. I wrote the same behavior as an enum. block_on, Delay, and delay are unchanged from the previous example; only handler and main are replaced.

enum Handler {
    Start,
    WaitFirst(Delay),
    WaitSecond(Delay),
    Done,
}

impl Future for Handler {
    type Output = &'static str;

    fn poll(mut self: Pin<&mut Self>, cx: &mut Context<'_>) -> Poll<&'static str> {
        loop {
            match &mut *self {
                Handler::Start => {
                    println!("  [handler] start");
                    *self = Handler::WaitFirst(delay(50));
                }
                Handler::WaitFirst(first) => {
                    if Pin::new(first).poll(cx).is_pending() {
                        return Poll::Pending;
                    }
                    println!("  [handler] after first delay");
                    *self = Handler::WaitSecond(delay(30));
                }
                Handler::WaitSecond(second) => {
                    if Pin::new(second).poll(cx).is_pending() {
                        return Poll::Pending;
                    }
                    println!("  [handler] after second delay");
                    *self = Handler::Done;
                    return Poll::Ready("done");
                }
                Handler::Done => panic!("polled after completion"),
            }
        }
    }
}

fn main() {
    let output = block_on(Handler::Start);
    println!("output = {output}");
}
[executor] poll #1
  [handler] start
[executor] Pending -> park
    [waker] wake -> unpark executor
[executor] poll #2
  [handler] after first delay
[executor] Pending -> park
    [waker] wake -> unpark executor
[executor] poll #3
  [handler] after second delay
output = done

The output matches the async fn version line for line. Each enum variant is an .await point, and the Delay a variant holds is the future being awaited there. When the inner future returns Pending, the outer future passes Pending straight up. The type the compiler actually generates has no name, and its details differ from this enum. What I reproduced is only the structure: remember the state in an enum and continue from it on each poll.

Future size

A buffer whose scope crosses an .await is counted in the future's sizeno_buffer()2 Bbuffer_before_await()buf: [u8; 1024]1040 Bbuffer_in_block()16 Bbuffer_across_await()buf: [u8; 1024]1026 Bbuf (1024 B)rest (state, locals)

Each state has to hold the values that will be used again after the .await. That suggests the size of a future is set by the local variables that stay alive across an .await. I moved a 1KB array around and measured with size_of_val. YieldOnce is a future that returns Pending once, the first time it is polled.

use std::future::Future;
use std::pin::Pin;
use std::task::{Context, Poll};

struct YieldOnce {
    yielded: bool,
}

impl Future for YieldOnce {
    type Output = ();
    fn poll(mut self: Pin<&mut Self>, cx: &mut Context<'_>) -> Poll<()> {
        if self.yielded {
            return Poll::Ready(());
        }
        self.yielded = true;
        cx.waker().wake_by_ref();
        Poll::Pending
    }
}

fn yield_once() -> YieldOnce {
    YieldOnce { yielded: false }
}

async fn no_buffer() -> usize {
    yield_once().await;
    1
}

async fn buffer_before_await() -> usize {
    let buf = [0u8; 1024];
    let n = buf.len();
    yield_once().await;
    n
}

async fn buffer_across_await() -> usize {
    let buf = [0u8; 1024];
    yield_once().await;
    buf.len()
}

async fn buffer_in_block() -> usize {
    let n = {
        let buf = [0u8; 1024];
        buf.len()
    };
    yield_once().await;
    n
}

fn main() {
    println!("no_buffer           = {} bytes", size_of_val(&no_buffer()));
    println!("buffer_before_await = {} bytes", size_of_val(&buffer_before_await()));
    println!("buffer_in_block     = {} bytes", size_of_val(&buffer_in_block()));
    println!("buffer_across_await = {} bytes", size_of_val(&buffer_across_await()));
}
no_buffer           = 2 bytes
buffer_before_await = 1040 bytes
buffer_in_block     = 16 bytes
buffer_across_await = 1026 bytes

buffer_across_await uses buf after the .await, so the 1KB is part of its state. buffer_before_await copies buf.len() into n before the .await and never touches buf again, yet it came to 1040 bytes. It looks like buf was stored as a variable that lives across the .await because its scope runs to the end of the function, with n stored alongside it. buffer_in_block, which closes the scope with a { } block before the .await, came to 16 bytes. On rustc 1.94.1, what decided the size was not where a variable was last used but whether its scope crossed the .await. A --release (-O) build gave the same four numbers.

A future usually becomes a task through tokio::spawn and is stored on the heap, and any future you .await is stored inline inside the outer one. Letting a large buffer’s scope cross an .await grows the memory of each task by that much.

Pin

Moving a future that points at its own field leaves the reference on the old address, so Pin forbids the movefuture after first poll (address A)buf: [u8; 16]head: &buf[..4]move itaddress A (vacated)where buf used to beaddress B (moved future)buf: [u8; 16]head: &buf[..4]head still points herepoll(self: Pin<&mut Self>, ...)a promise not to move it until it is dropped

An async fn body can carry a reference to one of its own locals across an .await. Once the body becomes a state machine, that local and the reference are both fields of the same future value: a value that points at another of its own fields. The std::pin module docs explain that if such a self-referential value is moved, the pointer still points to the old address and becomes invalid, and they name the state machines the compiler generates for async fn as the key example.

The same docs split the life of such a value into stages. Right after it is created it can be moved freely; getting a future back from an async fn call is that stage. From the first poll on, the value assumes its address will not change, and later polls depend on that assumption. Pin<Ptr> marks in the type a promise that the value it points to will not be moved until it is dropped. That is why poll takes self: Pin<&mut Self>.

// YieldOnce and yield_once are the same as in the previous example (omitted)

async fn checksum() -> usize {
    let buf = [1u8; 16];
    let head = &buf[..4];
    yield_once().await;
    head.iter().map(|b| *b as usize).sum()
}

fn require_unpin<F: Future + Unpin>(_fut: &F) {}

fn main() {
    require_unpin(&yield_once());
    require_unpin(&checksum());
}
error[E0277]: `{async fn body of checksum()}` cannot be unpinned
  --> pin_err.rs:36:19
   |
25 | async fn checksum() -> usize {
   |                        ----- within this `impl Future<Output = usize>`
...
36 |     require_unpin(&checksum());
   |     ------------- ^^^^^^^^^^^ within `impl Future<Output = usize>`, the trait `Unpin` is not implemented for `{async fn body of checksum()}`
   |     |
   |     required by a bound introduced by this call
   |
   = note: consider using the `pin!` macro
           consider using `Box::pin` if you need to access the pinned value outside of the current scope
note: required because it appears within the type `impl Future<Output = usize>`
  --> pin_err.rs:25:24
   |
25 | async fn checksum() -> usize {
   |                        ^^^^^
note: required by a bound in `require_unpin`
  --> pin_err.rs:32:30
   |
32 | fn require_unpin<F: Future + Unpin>(_fut: &F) {}
   |                              ^^^^^ required by this bound in `require_unpin`

The line numbers are from the file before YieldOnce was omitted. Unpin is the auto trait for types that are fine to move. It is implemented automatically when every field is Unpin, so YieldOnce, which holds a single bool, passed. The future from checksum() is not Unpin and was rejected. Switching to an async { 1 } block with no references gave the same E0277. On rustc 1.94.1, futures from async blocks and async fn were not Unpin whether or not they actually held a self-reference.

The fix is what the note suggests: pin it, then use it. The earlier block_on pinned the future on the stack with pin! before polling it. If it has to leave the current scope, Box::pin pins it on the heap. require_unpin(&Box::pin(checksum())) compiled, because Pin<Box<_>> is just a pointer to a heap address; moving the pointer does not change where the future lives. The hand-written Handler enum could poll its inner Delay with a plain Pin::new for the same reason: Delay’s fields are a u64 and an Arc, so it is Unpin.

Work stealing in tokio’s multi-thread runtime

A tokio worker takes tasks from its local queue, then the global queue, and steals from another worker's local queue when both are emptywake outside the workersglobal queueworker 0running tasklifo slot (not stealable)local queue (max 256)worker 1running tasklifo slot (not stealable)local queue (max 256)wakeswakeswhen local is empty, or periodicallyif local and global are empty, take half of another local

tokio turns each future passed to tokio::spawn into a task and polls tasks that have been woken. The multi-thread runtime starts one worker thread per CPU core by default. The tokio::runtime module docs for tokio 1.54.1 describe the structure below as “behavior at the time of writing” and state that it may change in future versions.

  • Each worker has its own local queue, and the runtime has one global queue
  • A local queue holds at most 256 tasks. When it overflows, half of them move to the global queue
  • A worker checks its local queue first and only takes from the global queue when the local one is empty or after taking from local global_queue_interval times in a row. If that value is not set, the runtime computes it so that the global queue is checked roughly every 10ms
  • When both local and global queues are empty, the worker steals half the tasks from another worker’s local queue
  • When a task wakes another task, the woken task goes into the worker’s lifo slot instead of a queue and runs as soon as the current task’s poll returns. Other workers cannot steal the task in the lifo slot
  • A task woken from a thread that is not a worker goes to the global queue

I spawned 200 tasks from inside a single task and counted the name of the thread that ran each one.

use std::collections::BTreeMap;
use std::sync::atomic::{AtomicUsize, Ordering};
use std::time::Duration;
use tokio::runtime::Builder;

fn main() {
    static NEXT: AtomicUsize = AtomicUsize::new(0);
    let runtime = Builder::new_multi_thread()
        .worker_threads(4)
        .thread_name_fn(|| format!("worker-{}", NEXT.fetch_add(1, Ordering::Relaxed)))
        .build()
        .unwrap();

    let counts = runtime.block_on(async {
        // spawn 200 tasks from inside one task -> they land in this worker's local queue
        let spawner = tokio::spawn(async {
            let spawner_thread = std::thread::current().name().unwrap().to_string();
            let handles: Vec<_> = (0..200)
                .map(|_| {
                    tokio::spawn(async {
                        std::thread::sleep(Duration::from_millis(1));
                        std::thread::current().name().unwrap().to_string()
                    })
                })
                .collect();
            let mut counts = BTreeMap::new();
            for handle in handles {
                *counts.entry(handle.await.unwrap()).or_insert(0) += 1;
            }
            (spawner_thread, counts)
        });
        spawner.await.unwrap()
    });
    println!("spawned on {}", counts.0);
    for (thread, count) in counts.1 {
        println!("{thread}: {count} tasks");
    }
}
spawned on worker-1
worker-0: 50 tasks
worker-1: 53 tasks
worker-2: 47 tasks
worker-3: 50 tasks

The std::thread::sleep(1ms) inside each task is there on purpose: it keeps tasks from finishing instantly so other workers have time to take them. As the next section shows, it is a call to avoid in real code. Across three runs the spawning worker was different each time, and the four workers ran 47 to 53 tasks each. 200 is below the local queue limit of 256, so nothing overflowed into the global queue; I counted any task that ran on a worker other than the spawning one as stolen. Stealing is done by workers with nothing to run. If every worker is stuck inside some task’s poll, no worker is left to take the tasks piling up in the queues.

Blocking calls and task delay

thread::sleep inside a task holds a worker and delays ticker; spawn_blocking runs it on separate threadsstd::thread::sleep(100ms) inside a taskworker 0worker 1tickerjobjobjobjobno free workermoved to spawn_blockingworker 0worker 1tickerblocking 1blocking 2blocking 3blocking 4freefreethread::sleepthread::sleepthread::sleepthread::sleep0ms100ms200ms

A worker picks the next task only after the current task’s poll returns. The Future::poll docs say a poll implementation should return quickly and should not block, and that work which may take a while should be offloaded to something like a thread pool. The fairness guarantee in the tokio runtime docs is likewise conditioned on no task blocking the thread.

On a runtime with two workers I kept a ticker task running that wakes every 10ms, and ran four 100ms jobs concurrently in three different ways. ticker wakes 30 times and records how late it woke each time.

use std::time::{Duration, Instant};
use tokio::runtime::Builder;

#[derive(Clone, Copy, Debug)]
enum Job {
    AsyncSleep,
    ThreadSleep,
    SpawnBlocking,
}

const TICK: Duration = Duration::from_millis(10);
const JOB_TIME: Duration = Duration::from_millis(100);

// wake every 10ms and record how late each wakeup was
async fn ticker() -> Vec<Duration> {
    let mut lateness = Vec::new();
    for _ in 0..30 {
        let start = Instant::now();
        tokio::time::sleep(TICK).await;
        lateness.push(start.elapsed().saturating_sub(TICK));
    }
    lateness
}

async fn run_job(job: Job) {
    match job {
        Job::AsyncSleep => tokio::time::sleep(JOB_TIME).await,
        Job::ThreadSleep => std::thread::sleep(JOB_TIME),
        Job::SpawnBlocking => tokio::task::spawn_blocking(|| std::thread::sleep(JOB_TIME))
            .await
            .unwrap(),
    }
}

fn run(job: Job) {
    let runtime = Builder::new_multi_thread()
        .worker_threads(2)
        .enable_all()
        .build()
        .unwrap();
    runtime.block_on(async {
        let ticks = tokio::spawn(ticker());
        tokio::time::sleep(Duration::from_millis(20)).await;

        let started = Instant::now();
        let jobs: Vec<_> = (0..4).map(|_| tokio::spawn(run_job(job))).collect();
        for handle in jobs {
            handle.await.unwrap();
        }
        let jobs_elapsed = started.elapsed();

        let mut lateness = ticks.await.unwrap();
        lateness.sort();
        println!(
            "{:<13} jobs {:>4.0?}  tick lateness p50 {:>6.1?}  max {:>6.1?}",
            format!("{job:?}"),
            jobs_elapsed,
            lateness[lateness.len() / 2],
            lateness[lateness.len() - 1],
        );
    });
}

fn main() {
    for _ in 0..3 {
        for job in [Job::AsyncSleep, Job::ThreadSleep, Job::SpawnBlocking] {
            run(job);
        }
    }
}
AsyncSleep    jobs 103ms  tick lateness p50  2.0ms  max  9.8ms
ThreadSleep   jobs 204ms  tick lateness p50  2.0ms  max 204.1ms
SpawnBlocking jobs 104ms  tick lateness p50  2.0ms  max  6.4ms
AsyncSleep    jobs 102ms  tick lateness p50  2.1ms  max  6.6ms
ThreadSleep   jobs 204ms  tick lateness p50  1.9ms  max 202.4ms
SpawnBlocking jobs 105ms  tick lateness p50  2.0ms  max  2.8ms
AsyncSleep    jobs 102ms  tick lateness p50  2.0ms  max  4.5ms
ThreadSleep   jobs 206ms  tick lateness p50  2.0ms  max 205.9ms
SpawnBlocking jobs 112ms  tick lateness p50  2.1ms  max  6.7ms
Only ThreadSleep pushed the worst ticker delay past 200msworst ticker delay (3 runs)AsyncSleep9.8ms6.6ms4.5msThreadSleep204.1ms202.4ms205.9msSpawnBlocking6.4ms2.8ms6.7ms0ms100ms200msload average 82–91, 2 workers, four 100ms jobs
  • In ThreadSleep, std::thread::sleep holds a worker for 100ms. Two workers ran the four jobs two at a time, one after another, so they took 204–206ms to finish. The worst delay was 202–206ms
  • In AsyncSleep, tokio::time::sleep returns Pending right away, so the workers stay free. The four jobs waited at the same time and finished in 102–103ms, with a worst delay of 4.5–9.8ms
  • SpawnBlocking ran the same std::thread::sleep on the blocking thread pool. Each of the four jobs got its own thread and they finished in 104–112ms, with a worst delay of 2.8–6.7ms
  • The median delay was around 2ms in all three cases. As the tokio::time::sleep docs note, the timer works at millisecond granularity, so that much appears even without blocking

Each job takes 100ms, yet in ThreadSleep the ticker ran about 200ms late. Going by the tokio docs, the order is this. A worker checks for timer events when it has no task to run, or after running 61 tasks in a row. When a worker finished its first job at 100ms, the queue still held a job, so it ran that next without checking the timer. Only at about 200ms, once both workers had finished their second jobs, was ticker’s timer handled. I did not trace tokio’s internals to confirm this order; I only checked that the measurements and the docs agree.

Because the machine was under heavy load, even the AsyncSleep worst case varied between 4.5 and 9.8ms from run to run. The 200ms in ThreadSleep is still an order of magnitude beyond that variation. I did not test a synchronous DB driver call, a std::fs read, or CPU work like parsing a large JSON body, but they share the property that matters here with std::thread::sleep: poll does not return until they finish, so they hold the worker.

Moving the work to spawn_blocking

spawn_blocking runs the closure on the blocking thread pool while workers poll other tasksworker threadsJoinHandle.await → Pendingpoll other tasksspawn_blocking(f)result → wakeblocking thread pool (max_blocking_threads, default 512)f1f2f3…past the limit, jobs wait in a queue (no backpressure)a job that has started does not stop on abortuse a dedicated thread::spawn thread for work that never ends

tokio::task::spawn_blocking runs a closure on a thread dedicated to blocking work and returns a JoinHandle for its result. The async task .awaits that JoinHandle, returns Pending, and frees its worker. Below is the behavior as the tokio docs describe it.

  • Blocking threads are added as requests arrive, and once the max_blocking_threads limit (512 by default) is reached, work is queued. The queue has no backpressure and can grow without bound
  • The limit is large because the pool is mostly used for I/O that cannot be done asynchronously. If you send a lot of CPU work there, the docs recommend limiting how many run at once with a semaphore or similar, and also point to dedicated CPU executors such as rayon
  • A spawn_blocking job that has started does not stop when you abort it, and runtime shutdown waits for started jobs to finish
  • Jobs that never end, or run for a long time, keep occupying a blocking-pool thread, so the docs say to create a dedicated thread with thread::spawn for them
  • Even on the current-thread runtime, spawn_blocking creates separate threads

When spawn_blocking fits:

  • Calling a library that only has a synchronous API (a synchronous DB driver, the file system)
  • Short blocking work that eventually finishes
  • Work that belongs to a single request, where you need the result back through .await

When a dedicated thread::spawn thread fits:

  • A background loop that runs for as long as the process is alive
  • Work that runs long enough to keep a blocking-pool thread occupied
  • Cases where you need to manage the number of threads and their lifetime yourself

Both lists are based on the tokio docs. What this post checked directly is only that moving std::thread::sleep to spawn_blocking reduces the delay of other tasks.

Wrapping up

A Future turned out to be a state machine that advances to the next .await and returns each time it is polled. tokio polls these futures in turn on a few workers, so other tasks get their turn only if poll returns quickly. When four 100ms blocking jobs occupied two workers, a 10ms timer ran about 200ms late; moving them to spawn_blocking brought it back to the few milliseconds seen without blocking.

Looking back over the series, the compiler checked most of the rules, from ownership to Send. The assumptions inside unsafe and async’s “poll does not block” are ones the compiler does not look at, so the person writing the code has to keep them.

References

Rust study series (10 posts)

  1. Rust Ownership and Freeing Memory: the rule that an owner is dropped at the end of its scope
  2. Rust Move, Copy, and Clone: how assignment and argument passing move ownership
  3. Rust References and Borrowing: borrowing rules for shared and mutable references
  4. Rust Lifetimes: the contract that records which input a returned reference came from
  5. Rust Traits, Generics, and dyn: static and dynamic calls through trait bounds and dyn Trait
  6. Rust Closures and Iterators: closures that become structs holding their captured values
  7. Rust Smart Pointers: Box, Arc, Mutex, and Send and Sync
  8. Rust Memory Layout and Allocation: enum and struct sizes measured with size_of
  9. Rust unsafe Boundaries: the author answering for assumptions the compiler cannot check
  10. Rust async and the tokio Scheduler — this post

External