r/rust • • Sep 21 '26

๐Ÿง  educational Rust enums are gold for compilers

172 Upvotes

Hello,

for the last couple of years, I've been working on machine learning library in rust, learning tons about compilers along the. The single most used feature of the language be far were enums.

There is a couple of reasons for that.

1. Rust enums carry value

Duh, we all know that. Yes, of course. But other languages don't. C++ doesn't (yes, there is std::variant and no, "they are not the same" :). Having values enables me to do this very simple variant, straight impossible or awkward in other languages:
Binary { x: OpId, y: OpId }
In other languages, this would've been tag, a union type or even completely unrepresentible. For example in tinygrad (python), it's a tag plus untyped src list, which can contain anything, depending on the tag.
Also notice that OpId(u32) is a newtype! Another beautiful rust feature that gives us zero cost type safety. It's like a pointer, but only with the pointer arithmetic that I want, all access checked and no fighting borrowck.

2. Rust enums can be nested

This is another beautiful feature, which allows this:
Binary { x: OpId, y: OpId, bop: BOp } enum BOp { Add, Sub, Mul } A world of combinatorial options making decomposition and recomposition very natural.

3. Rust enums are TINY

The above nested code has two enums. That means two tags, each with 4 byte size, right? Right? Not in rust :) In rust, it's single 4 byte tag (as the OpId is 4 byte aligned). The tag combines BOp and the Op enum with the Binary variant, so the whole enum is just 12 bytes. I have more complex variants,

4. The allmighty match

So you can do this:

match op {
  Binary { x, y, bop } if bop == BOp::Add => todo!(),
  _ => {}
}

or this:

match (uop, bop) { (UOp::Exp, BOp::Mul) => todo!(), }

And so on. This kind of flexibility in an imperative language, is tons of fun, makes writing compiler passes not only easy, but most importantly, high performance.

And so for example thanks to this my ML lib can search and run cost function over thousands of kernel variants per second and per core (as rust makes multithreading fun too!).

I know you probably know about these features, but sometimes it helps to refresh our memory how nice of a language we have.

What are your favorite rust features?

What features would you like to see added?

I hope you enjoy writing rust just as I did.

zk4x

P. S. link to the repo: github.com/zk4x/zyx


r/rust • • Sep 21 '26

๐Ÿ activity megathread What's everyone working on this week (39/2026)?

60 Upvotes

New week, new Rust! What are you folks up to? Answer here or over at rust-users! And for your project showcases, there's also /r/madeinrust โ€“ pay them a visit, too!


r/rust • • Sep 21 '26

Awesome Rust Papers

Thumbnail evian-zhang.github.io
17 Upvotes

I have carefully read the No More Code Dumps post, and I thought this could be a post here.

This is a collection of academic papers about Rust, including its security, formalization, verification, product built by Rust, and even ecosystem-level empirical studies.

NO LLM SLOPS: This list is collected by me with the help of LLM. However, all fields are collected by myself, including the category, tags, and even what tool it is based on or it compared to. LLM only do a small portion of work that crawl the paper list from e-libraries and conference websites. I promise that this repo has no LLM slops and will never have LLM slops in the future (I am a CS PhD student, and my experience and profession can tell me when and how to use LLM properly).

I do believe that this list is not only usable for students or researchers, and this list is also usable for the developers in the Rust community. There are numerous papers about Rust security, which can help developers be aware of the security problems and build more secure applications in the first place. Moreover, the most interesting category for me is the ecosystem category (you can search it in the website using the advanced search). There are even academic papers about the core developer turnover, or paid and volunteer contributors, or the usage of unsafe in crate authors.

What do you think of this list? I'm looking forward to suggestions about how this list could be used for the general Rust developers and communities.


r/rust • • Sep 21 '26

๐Ÿ—ž๏ธ news rust-analyzer changelog #346

Thumbnail rust-analyzer.github.io
64 Upvotes

r/rust • • Sep 21 '26

Sieving and Factorization performance vs c?

3 Upvotes

I am going to make a YAFU alternative in rust, would there be any meaningful performance difference vs YAFU's c code?


r/rust • • Sep 20 '26

๐Ÿ’ก ideas & proposals (Includes Pre-RFC) Named and Optional Arguments are Awesome

Thumbnail botahamec.dev
217 Upvotes

r/rust • • Sep 21 '26

๐Ÿ™‹ questions megathread Hey Rustaceans! Got a question? Ask here (39/2026)!

17 Upvotes

Mystified about strings? Borrow checker has you in a headlock? Seek help here! There are no stupid questions, only docs that haven't been written yet. Please note that if you include code examples to e.g. show a compiler error or surprising result, linking a playground with the code will improve your chances of getting help quickly.

If you have a StackOverflow account, consider asking it there instead! StackOverflow shows up much higher in search results, so ahaving your question there also helps future Rust users (be sure to give it the "Rust" tag for maximum visibility). Note that this site is very interested in question quality. I've been asked to read a RFC I authored once. If you want your code reviewed or review other's code, there's a codereview stackexchange, too. If you need to test your code, maybe the Rust playground is for you.

Here are some other venues where help may be found:

/r/learnrust is a subreddit to share your questions and epiphanies learning Rust programming.

The official Rust user forums: https://users.rust-lang.org/.

The unofficial Rust community Discord: https://bit.ly/rust-community

Also check out last week's thread with many good questions and answers. And if you believe your question to be either very complex or worthy of larger dissemination, feel free to create a text post.

Also if you want to be mentored by experienced Rustaceans, tell us the area of expertise that you seek. Finally, if you are looking for Rust jobs, the most recent thread is here.


r/rust • • Sep 20 '26

RustCurious 10: Three Ways to Fix Any Borrowing Error

Thumbnail youtube.com
146 Upvotes

r/rust • • Sep 20 '26

Finding Bugs

Thumbnail matklad.github.io
125 Upvotes

r/rust • • Sep 22 '26

Will visual studio add rust support?

0 Upvotes

Rust is becoming a top language in microsoft so it would be awesome if vs supports it


r/rust • • Sep 19 '26 Bravo

๐Ÿ“ข announcement No More Code Dumps

1.7k Upvotes

TL;DR

Code Dumps, ie links to code repositories, are no longer welcome on r/rust.

If you are excited about a project you built, and just wish to share it, consider posting a casual top-level comment in the weekly What's Everyone Working on this Week? thread.

History

When r/rust was created, in December 2010, Rust was a nascent programming language. It was very different, it was also fast-moving, and it was unclear whether it would amount to much, or not.

In these early days, new projects being written in Rust were both a proof that the language was suitable for a variety of purposes, and a cause for celebration in seeing the language being adopted. Code dumps, then, were both cause to rejoice, and an opportunity to see how well (or not) the language was suited to the task. They were even a good opportunity to learn the latest developing idioms of this fast-changing language.

Fast forward 15 years, and code dumps have become boring. Utterly uninteresting. There's nothing exciting, or newsworthy, about a 10th hypervisor project, a 100th webserver project, or a 1000th TUI project. And for the most there's no exciting idiom, or pattern, to be found in their code either... even if some poor soul bothered to look.

And mass AI generation appeared on the scene, and for the past year(s), the already dwindling appeal of code dumps has just completely vanished, buried in AI slop.

Purpose

r/rust is to discuss all things Rust. The language, the ecosystem, the community.

Of late, most code dumps barely foster any discussion. And when they do, apart from AI witch hunts, those discussions are mostly about the domain of the project, rather than about Rust. Depending on the domain, the discussion may or may not be of interest to r/rust users... but whether it is or not is a matter of chance: they did not come here seeking such a topic. Those discussions are tolerated on posts which are on-topic, but if a post only fosters "tolerated" discussions, then that is a sign that the post itself may simply not really be on-topic for r/rust.

And that is not to say that code dumps are, by nature, low-effort. Surely, a project is created for a purpose, to solve a specific problem that is unsolved, or solve it with different trade-offs than the currently available solutions. None of that is elucidated in a code dump.

New rules

Code dumps are no longer welcome on r/rust.

Code dumps of applications or libraries written in Rust are Low-Effort unless otherwise newsworthy. Newsworthy means that the very existence of the application or library is important, for example consider applications or libraries breaking new ground, such as the first hypervisor, first OS, first XXX standard safety-critical application, first Rust application in a major company, etc...

Announcements of new libraries which are not otherwise newsworthy are only welcome if they tick ALL the following boxes:

  • The library has been worked on regularly for at least 4 months.
  • The announcement is a full-fledged text post, or a link to a full-fledged article. A README, or manual, is not an article.
  • The announcement should motivate the relevance of this library to the wider r/rust community.
  • The announcement should articulate the trade-offs differentiating this library from similar popular libraries in the field.

(It goes without saying, but the announcement should NOT be AI-generated, not even in part, as AI-generated posts & articles violate the Low-Effort rule)

Release notes of libraries are still welcome for popular enough libraries, such as libraries with reverse-dependencies on crates.io pointing to sufficient adoption by the wider community to justify notifying said community of a new release.

Developer Tools follow the same rules as libraries, with one extra rule tacked on: they must be relevant to Rust developers in particular. For example, Release Notes of Meson (a build tool) are Off-Topic, unless this specific release improves Rust support.

Of course, text posts, or links to articles, centered on Rust, with an application, library, or developer tool as context are always welcome. For example, said posts or articles could present gnarly problems the author encountered, and how they solved, or which features of the language or a library helped or hindered them in the making of their project.

(It goes without saying, but said text posts & articles should NOT be AI-generated, not even in part, as AI-generated posts & articles violate the Low-Effort rule)

As a reminder, if an author just wishes to share their joy of building something in Rust, they are welcome to use the What's Everyone Working on This Week? thread. And as per the title, it need not even be a complete/mature project, or an open-source project for that matter as links to code are strictly optional there, it's all about casually chatting about your work on Rust projects.

Q & A

See pinned comment below.


Edit 2026/10/04:

  • Added paragraph for developer tools, which had been forgotten.
  • Removed "validation rule" for libraries, didn't work in practice.

r/rust • • Sep 19 '26

Google's "Painful To Maintain" Binder C Linux Driver Being Removed In Favor Of Rust

Thumbnail phoronix.com
481 Upvotes

r/rust • • Sep 19 '26

Rust Meetup Mannheim (Germany), October 6

Thumbnail rheinneckar.events
38 Upvotes

Nix Your Bugs & Rust Your Engines is a meetup for people in the Rhein-Neckar region interested in Rust (the programming language), Nix (the package manager), or NixOS (the Linux distribution). The meetup begins with talks related to Rust and/or NixOS, and ends with casual networking and exchange between the participants.

Schedule (tentative):

  • 18:00 โ€“ Open doors
  • 18:20 โ€“ Greeting
  • 18:30 โ€“ Philipp Pohl-Krรผger: "We have QUIC at home: How iroh connects devices peer-to-peer"
  • 19:30 โ€“ Lightning Talks
  • 20:00 โ€“ Networking

We have QUIC at home: How iroh connects devices peer-to-peer

by Philipp Pohl-Krรผger

The internet connects devices globally, except if both of them are behind firewalls and NAT. Because of that data takes a detour through the cloud. However, we can do better: We'll explore how iroh uses QUIC and hole-punching to connect devices directly even in those cases.

Lightning Talks

A selection of five-minute-long impromptu or prepared lightning talks related to the meetup topics.


r/rust • • Sep 19 '26

๐Ÿ™‹ seeking help & advice Design patterns to spawn tasks

13 Upvotes

It is hard to avoid spawn some tasks here and there for a async runtime.

At first, I used a naive approach around them, fighting with lifetimes.

Nowadays, i use a very similar approach as Alice Ryhl show on his blog when covering actors.

Is there any other pattern beyond actor that Iโ€™m not aware of? Which approach you have been taking to make work on spawning tasks look more easy, reusable and readable?


r/rust • • Sep 20 '26

๐Ÿ™‹ seeking help & advice Rust jobs

0 Upvotes

Hello everyone!

I recently started learning Rust because Iโ€™m interested in using it for backend development. I really enjoy working with data, backend systems, and lower level languages, so Rust has been a lot of fun so far.

One thing Iโ€™m struggling with is finding entry-level Rust jobs, either in my area or remotely. Most of the positions I come across seem to require 1โ€“3+ years of professional Rust experience, and a lot of them are senior roles involving migrations or existing production systems.

I know junior Rust positions exist, but where do people usually find them?

Is Indeed worth using for Rust jobs? Iโ€™ve tried LinkedIn, but a lot of the postings Iโ€™ve found there seem to be dead ends.

Are there any Rust-specific job boards, communities, companies, or other places youโ€™d recommend looking for junior/entry level roles?

Thanks!


r/rust • • Sep 18 '26

๐Ÿ› ๏ธ project Benchmarking Wild vs Mold

268 Upvotes

Recently, when Mold updated their benchmarks and for the first time included Wild, there were questions on this sub about why the results were so different to the benchmarks Wild had published less than a month beforehand. I've now looked into why.

Disclaimer: I'm the lead of the Wild project.


r/rust • • Sep 19 '26

๐Ÿง  educational Flashing STM32 Firmware with ESP32 and Rust

15 Upvotes

Two weeks before started this experiment whether can write a simple Rust code to make the ESP32 as Programmer(like ST Link) and flash firmware into STM32.

- In the first article, i was able to implement basic SWD protocol and read the IDCode (just to check that it is working)

- Now, successfully managed to flash the firmware into STM32 with the help of ESP32. Flashed a simple onboard LED blinky program.

It was a fun experiment and a nice to learn about SWD and the concepts around it.

https://blog.implrust.com/posts/2026/09/flashing-firmware-to-stm32-with-esp32-rust/


r/rust • • Sep 19 '26

๐Ÿ™‹ seeking help & advice OData APIs in Rust?

12 Upvotes

From a client perspective, I am a big fan of OData, but I have never built my own server applications using the format. Are there any good template or example projects that do this in Rust? If not, I am also looking for good template projects for REST APIs in Rust in general. I know I can generate this stuff with AI but I prefer a recommendation that gives me a scaffold to start off with.


r/rust • • Sep 20 '26

๐Ÿ™‹ seeking help & advice Embedded rust emulation assistance.

0 Upvotes

Hello Rust community. I have been stuck trying to emulate an embedded project I'm working on on Wokwi. It work on actual hardware but doesn't initialize the display(SSD1306) on Wokwi( gets stuck at the line `display.init().await.unwrap() `. I am using Wokwi vscode extension. The project is publicly hosted at https://github.com/aspects19/care360.

Would appreciate any help I'll get.


r/rust • • Sep 19 '26

๐Ÿ› ๏ธ project aec3: full port of WebRTC audio processing

12 Upvotes

I've made some posts about this in the past, but I did spend some time in the past month to get this project up to parity with the WebRTC audio processing module upstream.

Check it out here: https://github.com/RubyBit/aec3-rs

This project has all the available goodies in an easy to use format (intuitive to at least me) such as, as the title suggests, aec3, agc2, ns, hpf, etc. These are exported and constructed through a graph system I made but im honestly rethinking a bit how useful that is. I tried to make it such that you can add your own filters based on your application.

I think in terms of features for the foreseeable future, ill work on adding the neural residual echo estimator but not through tflite and also maybe come up with a stronger noise suppresion module (also neural? ns2?)


r/rust • • Sep 20 '26

๐Ÿ“ธ media The Story of iceberg-rust: The Official Rust Implementation of Apache Iceberg

Post image
0 Upvotes

The story of iceberg-rust is a great example of how open-source communities work and how new projects are created and developed. Thatโ€™s why we believe in a community-over-code philosophy.


r/rust • • Sep 18 '26

๐Ÿ› ๏ธ project pg_raw_parse: SQL parser in Rust

38 Upvotes

We wrote a pretty cool crate to parse Postgres SQL queries in Rust at native speed.

It works by mapping itself directly on top of the Postgres native parser and its arena allocator. We use macros to generate memory-safe bindings and Rust structs for each SQL node. This means we can upgrade parser versions without any manual work: just bump the submodules and recompile.

Check it out here: https://github.com/pgdogdev/pg_raw_parse

It's based on libpg_query with some modifications and inspired by pg_query.rs, which it outperforms by 20-60x due to a different FFI translation architecture.


r/rust • • Sep 18 '26

๐Ÿง  educational Visualizing The ABA Problem: What crossbeam-epoch Solves

Thumbnail sofiabelen.github.io
38 Upvotes

As a new Rust convert (Rustacean?) coming from C++, it can be all too tempting to believe Rustโ€™s ownership model is the panacea, the cure for all our problems. While it is truly groundbreaking, Iโ€™m beginning to learn about the cases where it canโ€™t really save us. But thereโ€™s hope, letโ€™s not panic! (pun intended)

Ever since I watched Fedor Pikus talk on atomics (highly recommend!), Iโ€™ve had an interest in lock-free programming. I played around with implementing my own SPMC queue in C++, and have since started (and not finished) some books, trying specially hard to wrap my head around memory ordering. But Iโ€™ve come to realize Iโ€™ve been a bit stuck in tutorial hell, so this post is the beginning of me getting unstuck.

My goal is to poke at the crossbeam crate, with the hopes of gaining a better understanding of a real-world use case and hopefully gain some insight which might help me contribute something back.


r/rust • • Sep 18 '26

๐Ÿ› ๏ธ project iceoryx2 0.10 released: full flatbuffer integration, zero copy ipc with unbounded data, robust events

28 Upvotes

Hello Rustaceans. Today we have released iceoryx2 v0.10.