Rust async and the tokio Scheduler

Calling an async fn runs none of its body; it only produces a Future value. A Future is a state machine that advances to the next await each time it is polled, and when it cannot advance it leaves a Waker behind and returns Pending. After the first poll its state depends on its own address, so Pin keeps it from being moved. On a tokio runtime with two workers, four std::thread::sleep(100ms) jobs occupied both workers and delayed a task that wakes every 10ms by about 200ms; moving the same jobs to spawn_blocking brought the delay back to the few milliseconds seen without blocking. The tenth and final post in a Rust study series.

November 17, 2026 · 20 min read

Rust Closures and Iterators

A closure is a struct whose fields are the values it captures, and whether its body reads, mutates, or consumes those values decides whether it is Fn, FnMut, or FnOnce. Iterator adapters only stack up structs that hold such closures; elements pass through the chain one at a time when a consuming method like collect calls next. The sixth post in a Rust study series.

November 17, 2026 · 19 min read

Rust Memory Layout and Allocation

The same three-field struct takes 12 bytes when it keeps declaration order and 8 when the compiler picks the order. Option<&T> is 8 bytes like the pointer itself, with no tag, and a Vec keeps 24 bytes on the stack and its elements on the heap. Sizes were checked with size_of and the effect of removing allocations with criterion. The eighth post in a Rust study series.

November 17, 2026 · 18 min read

Rust Smart Pointers

A linked list written as a plain enum fails with E0072, and an Rc sent to a thread fails with E0277. Box lifts the rule that sizes must be known at compile time, while Rc, RefCell, Arc, and Mutex each relax the one-owner, no-overlapping-borrows rule, paying with a heap allocation, count updates, run-time checks, or locking. The seventh post in a Rust study series.

November 17, 2026 · 20 min read

Rust Traits, Generics, and dyn

Generics (including argument-position impl Trait) compile a copy of the function for each type it is called with and call it statically. dyn Trait compiles one function that reads the implementation’s address from a vtable. I treat the choice as depending on whether types must be mixed, and on whether the cost of extra copies or of indirect calls is the one that hurts. The fifth post in a Rust study series.

November 17, 2026 · 17 min read

Rust unsafe Boundaries

The borrow checker still runs inside an unsafe block, so two mutable borrows there still give E0499. What unsafe opens is operations the compiler cannot check, such as dereferencing a raw pointer (the Rust Book lists five), and the author has to supply the reason each one is safe. I wrapped split_at_mut in a safe function and implemented Send by hand for a type holding a raw pointer, to see where that responsibility splits. The ninth post in a Rust study series.

November 17, 2026 · 17 min read

Rust Lifetimes

A lifetime annotation 'a does not make a value live longer. It is a contract stating which input a returned reference borrows from, and the borrow checker combines that contract with each reference’s last use to compute borrow regions. The fourth post in a Rust study series.

November 14, 2026 · 11 min read

Rust References and Borrowing

A Rust reference borrows a value without taking ownership. The compiler allows many shared references &T or a single mutable reference &mut T at a time, rejecting code that changes a borrowed value, and it also rejects references that would outlive their owner, all at compile time. The third post in a Rust study series.

October 29, 2026 · 13 min read

Rust Move, Copy, and Clone

In Rust, assignment and passing a function argument move ownership by default. Only Copy types are bitwise-copied and leave the original usable, and the cost of duplicating heap data shows up in the code as a clone() call. The second post in a Rust study series.

October 15, 2026 · 11 min read

Rust Ownership and Freeing Memory

Rust has no garbage collector. Every value has a single owner, and the value is dropped where that owner’s scope ends. Because the drop point is fixed by scopes in the source code, files and locks are cleaned up by the same rule as memory. The first post in a Rust study series.

October 8, 2026 · 9 min read