Rust Gets Tail Calls đŚ
Todayâs Issue: Lessons Learned From Rewriting UltraGraph, Implementing a Lock-Free Channel in Rust, and Const Trait Counterexamples
Hello, Rustaceans!
As we wrap up August, I hope you make this final week a success. Letâs learn!
In this issue, weâll discuss the Tail Call Optimization (TCO) feature currently in nightly, present you a Q/A interview, spotlight an amazing Rust project, and share ten (10) incredible links of the week.
Hereâs issue 81 for you!
MAIN NEWS
Rust Gets Tail Calls đŚ
If there's one conference you shouldn't miss as a Rustacean, it's RustConf, happening this year in Seattle from September 2â5, and available online for free if you're unable to attend in person.
One talk I'm especially looking forward to is âRust at the Last Mile in Healthcareâ by Ally Salim Jr.
And speaking of exciting developments, there's also great news on the language evolution front. Rust nightly recently shipped support for become keyword and explicit tail call codegen for the LLVM backend.
Tail Call Optimization (TCO) is especially promising for interpreter writers or anyone writing recursive algorithms that donât want to nuke memory.
So, what exactly is TCO? Think of TCO as the process by which a smart compiler can make a call to a function and take no additional stack space. When a functionâs last act is calling another function (or itself), TCO ensures it reuses the current stack frame instead of piling on the stack. Picture a function a calling b, where b takes over and returns directly to aâs caller.
The become keyword makes this explicit, so youâre not gambling on the compilerâs mood swings.
Below is a simple snippet to show TCO in action:
Note in the code snippet and in particular the factorial function uses become to tail-call itself, keeping stack usage constant.
Naturally, the question that often comes up is why not let the compiler figure it out? Isnât that its whole job? Well, in Rust, being explicit is key. Rust wants you to opt-in. That way, when become canât be honored, you get a compile-time error and not a panic. Pretty awesome right?
So is this a good move? Honestly, yeah. Rustâs strictness forces you to be intentional, unlike languages that might silently skip optimization or worse let your app crash. Itâs a power move for performance and safety sticklers alike. Plus, itâs a nod to Rustâs âyou got this, but Iâm watchingâ vibe.
Also note that TCO is still not ready for production and has some known bugs and issues, so tread carefully until this feature will be stabilized.
In conclusion TCO lets you write recursion without blowing your stack, by ensuring your function calls itself in a tail position explicitly.
Further Reading:
RUST Q/A INTERVIEW đŚ
Q: What excites you most about Rustâs future in the next 5 years?
A: âThis might be a bit out of left field, but I've been having a lot of fun with Bevy lately, so I'm happy to see where that's going (and the rest of the Rust gamedev scene).
It's also nice that async traits are finally getting out of the dyn-macro limbo that they were stuck in for so long!â
Q: Whatâs one feature youâd love to see added to Rust soon?
A: âDyn traits have always been kind of a second-class citizen.. They've, of course, been there since 1.0.. but there's always been this awkward set of restrictions around what they can do (in particular, the lack of associated types!) that meant you either had to restrict your trait impls to dyn-friendly code, or write a bunch of awkward adapter code every time. So dynosaur is a really encouraging (IMO) step towards having dyn Just Workâ˘ď¸ when you need it in more cases, without having to pay the "dyn cost" when you don't (unlike the olden days of async_trait)â
About the Respondent: Natalie Klestrup RĂśijezon is one of those weird "software engineers". In her free time she works on FlickBoard, a weird keyboard for Android. For work she wrangles Kubernetes into doing things it doesn't really want to.
Connect with Natalie: Mastodon, Blog, GitHub.
PROJECT SPOTLIGHT đĄ
Verus
Verus is a tool for verifying the correctness of code written in Rust. Developers write specifications of what their code should do, and Verus statically checks that the executable Rust code will always satisfy the specifications for all possible executions of the code.
It tackles one of the biggest headaches in low-level programming: trusting that your code wonât betray you at runtime.
Rather than adding run-time checks, Verus instead relies on powerful solvers to prove the code is correct.
Why Verus is actually pretty good:
Write specs directly in Rust-like syntax and let the solver do the heavy-lifting for you.
Static guarantees, no runtime hit - Verus proves properties at compile time, so thereâs zero performance hit at runtime.
Goes where Rust wonât - It handles tricky stuff like raw pointers and termination checking.
Backed by research & real-world use - Verus is actively used in academic and industry projects.
Though Verus is still in active development, it is a highly promising project and is available on GitHub at https://github.com/verus-lang/verus.
AWESOME LINKS OF THE WEEK đ
Jake Goulding on behalf of the Infrastructure team are Demoting x86_64-apple-darwin to Tier 2 with host tools, and the leadership council are Electing new Project Directors 2025.
Tweede golf team released an Update on their advocacy for memory-safe technology to reduce vulnerabilities, align with the European Cyber Resilience Act, and promote secure-by-design software development.
Drew from Filtra interviewed Mikayla Maki, a Software Engineer at Zed Industries, they discussed Zedâs company culture, unique hiring practices, problem-solving approaches, and the development of Zed.
Aram Drevekenin wrote about the development of Zellijâs web client, explaining how a single web server per machine uses websockets and a custom URL scheme to enable browser-based access to persistent terminal sessions, complete with a secure authentication model.
Beef (Project group lead for Rust's const traits) wrote about the complexities and design considerations of stabilizing const traits, with counterarguments to alternative proposals like implicit const bounds, and syntax choices.
The amazing Rustaceans at Databend wrote about Implementing a Lock-Free Channel in Rust for Databendâs Query Pipeline.
Jyn laments about the complexity of learning Rust due to its interwoven core concepts like first-class functions, generics, references, and the borrow checker, which make it challenging to understand non-trivial programs.
DeepCausality team wrote about the Lessons they learned from Rewriting UltraGraph in Rust.
Joseph Kain authored refactoring of a Rust-based debugger to support multiple breakpoints, transitioning from a C-style implementation with global state to a more idiomatic Rust design.
Steve Prydeâs âTesting failure modes using error injectionâ, explains how to test failure scenarios using error injection by building a reusable mechanism to simulate and control upload failures in unit tests.
CodeCrafters: Become a Better Rust Engineer
CodeCrafters created amazing Rust courses that push your skills beyond the basics.
Youâll have fun building real-world projects from scratch, including Git, Docker, Redis, Kafka, SQLite, Grep, BitTorrent, HTTP Server, an Interpreter, and DNS.
The courses are self-paced, so you can learn at your own speed. If youâre itching to level up your Rust skills, these courses are perfect for you.
Join for free and get 40% off when you upgrade. [affiliate]
SUPPORT RUST BYTES
Youâre Rust Bytesâ biggest fans, and we love to see it.
Hereâs how you can help spread the word:
â¤ď¸ Recommend Rust Bytes to your friends.
𤳠Connect with us on our socials: X, BlueSky, Mastodon, Publication.
âď¸ Support our editors by buying us coffee.
đ¨ Email us at rustaceanseditors@gmail.com for sponsorship, feedback or ideas.
I met new friends last week and had good discussions too. Stay hydrated!
That's all for now, Rustaceans.
John & Elley.



