AI 摘要The author argues that the newly proposed UnpinCell wrapper type, which converts a pinned mutable reference into a plain mutable reference, could solve the biggest outstanding problem with Rust generators: the Iterator interface does not permit self-referential values. Because Pin was designed as a backward-compatible, opt-in contract, pre-existing traits like Iterator—which takes a plain mutable reference rather than a pinned one—cannot be implemented by self-referential types. As a result, generators cannot support self-referential values the way async functions do, unless the Iterator interface adopts pinned references.
AI 摘要The author proposes a new Rust design, UnpinCell, as a variation on their earlier pinned places proposal. Whereas the previous design relied on the unusual concept of 'pinned fields' to support pinned projection, this new approach aims to offer similar properties while remaining consistent with Rust's standard field projection behavior, without introducing a special field marker.
AI 摘要The article explains that Rust's Pin type was designed in 2018 as a minimal, library-only solution to enable shipping async/await quickly, but this choice created a significant complexity cliff for users who must interact with pinned references, especially when implementing Future by hand. The author argues that these difficulties stem not from the inherent complexity of pinning as a concept, but from Pin being a pure library type lacking language support. The post proposes a set of fully backward-compatible language changes to make working with pinned references feel much closer to working with ordinary references.
AI 摘要The article discusses Pin, a foundational but widely misunderstood part of Rust's async ecosystem that supports self-referential types by preventing them from moving in memory. The author, who originally proposed adding Pin to Rust, acknowledges critiques (such as one from the makers of Mojo) that interacting with Pin creates a 'complexity cliff' for users, and aims to explain what Pin achieves, how it came to be, and why it is hard to use. The author promises to present ideas for resolving this complexity in a follow-up post.
AI 摘要This article explains how substructural type theory applies to programming language design, arguing that designers should use accessible metaphors like 'ownership' to help ordinary programmers understand concepts such as constructors, destructors, and preventing aliasing of objects that represent external resources. Using Rust's ownership model as the primary example, the author aims to demystify these ideas so they become more common knowledge among programmers. While the post contains nothing groundbreaking for experts, it includes notes critiquing certain aspects of Rust's implementation that the author believes are incorrect.
AI 摘要The article revisits C.A.R. Hoare's 1974 critique of references and pointers in high-level languages, in which he argued they reintroduce machine-code problems—such as address/content confusion, unconstrained mutation through aliasing, lack of independent meaning, and performance overhead—calling them 'a step backward.' The author contends that while Hoare's famous 'billion dollar mistake' was the null pointer, the industry's broader disregard of his warnings about pointers in general was a 'trillion dollar mistake,' because mutable, aliased state destroys the ability to reason locally about a program's behavior. Preventing accidental mutation of aliased state, the author concludes, is essential to building correctly functioning software.
AI 摘要The author reflects on insights from Russell Johnston suggesting that effect systems (like Koka's) and coroutines (like Rust's async functions and generators) are in some ways isomorphic, and has been weighing the advantages and disadvantages of each. A tweet from Will Crichton sharpened the contrast by characterizing effect handlers as combining static typing with dynamic scoping. Viewing this from a user-experience rather than theoretical perspective, the author sees that property as a useful jumping-off point for understanding how effect handlers and coroutines differ.
AI 摘要The article explores the problem of asynchronous clean-up in Rust, arguing that supporting await inside destructors is unrealistic due to issues like dropping values in non-async scopes, object safety and Send concerns for futures, implicit await points, and difficult-to-predict code generation. The author reframes the challenge as a general limitation of destructors that must return (), covering async clean-up and clean-up that returns values like Result. The proposed solution combines async future cancellation with a do...final construct, which the author argues are prerequisites for any linear type mechanism in Rust rather than alternatives to type-based approaches.
AI 摘要The article discusses FuturesUnordered, an abstraction from the Rust futures library that runs a dynamic collection of futures concurrently within a single task as a Stream. It contrasts this with multi-task concurrency (spawning tasks, which require 'static and cannot borrow parent state) and intra-task concurrency (joining futures, which can borrow state but only supports a static number), positioning FuturesUnordered as a hybrid that combines borrowing with dynamic arity. However, despite being a natural fit for certain patterns, FuturesUnordered has been implicated in frustrating bugs for async Rust users, which the author plans to investigate in the rest of the post.
AI 摘要The article examines the debate over the futures/promise abstraction and async/await syntax, contrasting Marius Eriksen's argument that futures' distinct type signature enables composable and expressive concurrency with Bob Nystrom's 'function coloring' critique that dividing functions into sync and async is a frustrating burden. The author sides with Eriksen, noting that some of Nystrom's criticisms apply to JavaScript's callback style rather than statically typed languages like Rust. The post sets out to re-examine async Rust's design, imagining a world where the difficulties of futures are resolved so that async Rust becomes not just as easy to use as non-async Rust, but a better experience overall.
AI 摘要The article discusses a Rust problem known as "Barbara battles buffered streams," based on Tyler Mandry's recent post, in which the buffering adapters from the futures library (Buffered and BufferUnordered) interact poorly with `for await` loops when the loop body contains asynchronous processing (i.e., await expressions). The author argues that visualizing control flow helps clarify the issue, and begins by illustrating how a normal for loop consumes a non-asynchronous Iterator, calling its `next` method and processing items until none remain.
AI 摘要The article discusses how the Pin API in Rust was designed so that high-level users would never need to interact with it, allowing futures to store self-references while remaining immovable during polling. However, Pin still leaks into high-level code in three ways: selecting a Future in a loop, calling Stream::next, and awaiting a Future behind a pointer. Two of these problems can be addressed through better AsyncIterator affordances, while the third stems from a design mistake that cannot be fixed without a breaking change.
AI 摘要The author follows up on a previous post by examining coroutines for asynchrony and iteration from a more abstract perspective. They explain that their earlier point about AsyncIterator being the product of Iterator and Future makes more sense when considering the 'base case' of code that is neither asynchronous nor iterative. The post also features another ASCII diagram to illustrate the concept.
AI 摘要The author argues that the Rust project should immediately stabilize AsyncIterator using the existing poll_next interface rather than continuing to pursue the alternative 'async next' design favored by some influential contributors. Responding to Yosh Wuyts' post defending the async next approach, the author finds its arguments uncompelling and reiterates that adopting poll_next now is the right course for the project.
AI 摘要The article marks four years since Rust's async/await feature shipped as a 'minimum viable product' in version 1.39.0, arguing that the project's failure to ship extensions to async/await since then is the primary controllable reason for async Rust's negative reputation. The author proposes a roadmap of features needed to improve the async Rust experience, organized by timeline: ones achievable in the next 18 months, ones requiring up to three years, and a potential longer-term language change.
AI 摘要The article, written by a key contributor to Rust's async/await design (2017-2019), addresses how community reception of async Rust has shifted from initial excitement to increasing criticism on forums like Hacker News. The author argues that, despite the perception of async Rust as a messy design, there was no viable alternative given Rust's constraints, and aims to explain the original context and rationale behind the design decisions.
AI 摘要The author addresses a controversy in the Rust community over async runtimes defaulting to multi-threaded, work-stealing executors, which critics melodramatically call 'the original sin' of Rust async for forcing Send and 'static bounds on code. The author finds these sweeping criticisms off-putting and argues that such claims are not credible technical arguments. They conclude that the industry's discourse around this debate is rather unserious.
I want to wrap up my consideration of the idea of adding new auto traits to Rust with some notes from a conversation I had with Ariel Ben-Yehuda. You can read these two previous posts for context: Changing the rules of Rust Follow up to “Ch
AI 摘要The author follows up on a previous post about introducing a new auto trait via Rust's edition mechanism, which would require the compiler to build an 'unbreakable firewall' preventing !Leak types from the new edition from interacting with old-edition code that assumes all values can be leaked. Despite optimistic responses from readers, the author notes this is very difficult to achieve. An example provided by Ariel Ben-Yehuda demonstrates that the problem is even harder to solve than one might expect.