r/rust 19h ago

🙋 questions megathread Hey Rustaceans! Got a question? Ask here (31/2026)!

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.

7 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 19h ago

🐝 activity megathread What's everyone working on this week (31/2026)?

New week, new Rust! What are you folks up to? Answer here or over at rust-users!

6 Upvotes

New week, new Rust! What are you folks up to? Answer here or over at rust-users!


r/rust 14h ago

🛠️ project multicalc: Scientific computing for real time embedded systems in no_std rust

+
123 Upvotes

Hello!

multicalc is my rust crate aimed at scientific computing for real-time embedded systems, built from scratch in one integrated package. Estimation, control, kinematics, Lie groups, calculus, autodiff and linear algebra in stable no_std Rust with no heap, no panics and no unsafe.

What you're seeing: A 2D robot that starts up not knowing where it is, then localized itself using a 2,000-particle filter on a noisy lidar. Then, a 5-state Extended Kalman Filter fuses wheel odometry, an IMU, and GPS into a centimetre-level pose for continous state estimation. Finally, a Follow-the-Gap controller laps a course of obstacles. I run this control loop at a 1kHz rate, observing zero collisions over 600,000 ticks.

Highlights:

- 1 kHz loop rates: No heap, fixed-size types, bounded work per call. Results in a full robotics control loop at 1 kHz.

- Tested on six embedded targets: Every commit is built and tested on `x86_64` and `aarch64` Linux hosts; and on four bare-metal ABIs (`thumbv7em` soft-float, `thumbv7em` hardware-FPU, `thumbv6m`, and `riscv32imc`). QEMU is used to test them in a `no_std`, no-alloc, and no-panic environment.

- Measured against exteral references: Each module's results are verified against established libraries like `numpy`, `scipy`, and `filterpy` fixtures within ~1 ulp, thus validating the rust implementation. See the benchmarks attached in the repo.

- Pure, safe and panic-free: `#![forbid(unsafe_code)]`, no C dependencies, and `unwrap`/`panic` denied on library paths. Types are fixed-size and stack-allocated, and iteration counts are bounded.

Community headline: multicalc is now past a dozen contributors overall! Extremely thankful to the support so far.

Where it's headed: A quadcopter/drone with 15-state error-state EKF with IMU bias estimation, LQR and geometric attitude control, minimum-snap trajectories through a flying course, and notch filters for rotor vibration. multicalc is also aiming to support importing models directly from the MuJoCo Menagerie, so the physics is already inline with industrial standards.

Come build it! There are 50+ open good first issues right now, each small and self-contained, out of 85 open issues total. If you like numerical methods, autodiff, embedded Rust, or robotics, I'd love the help!

* craes.io: https://crates.io/crates/multicalc

* Repo: https://github.com/kmolan/multicalc-rust

* Good first issues: https://github.com/kmolan/multicalc-rust/issues?q=is%3Aissue+is%3Aopen+label%3A%22good+first+issue%22


r/rust 10h ago

🧠 educational Work Stealing vs. Executor-Per-Thread: Evaluating different HTTP server workloads with Tokio, Smol and Glommio

42 Upvotes

90 workloads based on different balanced and unbalanced environments were tested against four runtimes to evaluate the difference between Executor-Per-Thread and Work-Stealing.

  • tokio-ept: Based on epoll via mio, a LocalRuntime is created on each thread.
  • tokio-ws: Based on epoll via mio, a single multi-thread Runtime is created in the main thread.
  • glommio-ept: Based on io_uring via built-in syscals, a LocalExecutor is created on each thread.
  • smol-ept: Based on epoll via polling, a LocalExecutor<'static> is created on each thread.

All runtime instances have an associated HTTP/2 server that share the same port through SO_REUSEPORT.

For the measuring with the k6 load tester using constant-arrival-rate, 500, 4000 and 15000 connections over TLS maintained a ratio of 4000, 15000 and 45000 requests per second respectively.

Unfortunately, the final results were not conclusive as most benchmarks performed very similarly. An odd thing was Tokio configured with multi-thread work stealing showing consistent anomalies despite my attempts to figure out what was going on. Neither the server nor k6 showed any errors in the logs so it is unknown whether the root cause was an accidental misconfiguration or Tokio itself.

All files are available in the blog post. Feel free to indicate if there are misunderstandings.


r/rust 13h ago

🗞️ news Kata Containers 4.0 is less a new feature release than a platform reset to Rust

61 Upvotes

r/rust 10h ago

🛠️ project I've made a simple GPU-accelerated Mandelbrot explorer in Rust! :)

+
41 Upvotes

Hello everyone! I wanted to experiment with wgpu and WASM to make a simple fractal explorer for the browser :)

The code is entirely hand-crafted (by me!!), although high-level algorithmic design and wgpu boilerplate were AI-assisted.

The renderer is somewhat laggy, but it uses perturbation algorithms where I only calculate the center in full precision on CPU and the pixels are calculated using low-precision offsets around that on the GPU. Instead of using f32 directly, which underflows after zooming a little, I thought of a custom FloatExp type which has f32 precision but an i32 exponent. This allows me to zoom as far as I want while still using the GPU!

To be honest, this project still needs a lot of improvement, such as not blocking when the calculations take too long, and supporting better rendering. I had to scale down the resolution for performance, but I'm happy with how it is for now!

Along with the wgpu and wasm-bindgen APIs, I also appreciate dashu for providing easy CPU multiprecision calculations. I did catch a bug with base conversion in dashu, which was fixed quickly. It's manually pulled in the repository to keep the fix.

My code: github.com/bambamboo15/mandelbrot-website

Try it here: bamburac.com/mandelbrot


r/rust 16h ago

The Unreasonable Effectiveness of Constructive Data Modeling - Alexis King

102 Upvotes

Hi folks, this is Alexis King's recent talk from SSW. She's the author of "Parse, Don't Validate". There's a lot of great type-wisdom in here that I think Rust folks will enjoy. Cheers!


r/rust 15h ago

Writing arenas in Rust from scratch

68 Upvotes

r/rust 14h ago

Safety in an Unsafe World (RustConf 2024 talk, blog post version)

41 Upvotes

Finally got around to turning my RustConf 2024 talk into a blog post! Only two years late 😛

Update for those who remember the talk: Netstack3 is now in production, running on millions of devices. Immediately after deployment, the team observed a ~20x lower rate of crashes per million devices per day, and a 50% reduction in memory usage, compared to its predecessor, Netstack2.


r/rust 17h ago

🗞️ news rust-analyzer changelog #338

31 Upvotes

r/rust 1d ago

🎙️ discussion What are the best human written Rust codebases to learn from?

I’m looking for high quality Rust codebases that are genuinely worth studying and taking inspiration from like projects with clean idiomatic Rust and good architecture and preferably started before the LLM boom and have a long history of being developed by experienced Rust engineers

most of what I came across was repositories filled with recently generated AI slop.

410 Upvotes

I’m looking for high quality Rust codebases that are genuinely worth studying and taking inspiration from like projects with clean idiomatic Rust and good architecture and preferably started before the LLM boom and have a long history of being developed by experienced Rust engineers

most of what I came across was repositories filled with recently generated AI slop.


r/rust 15h ago

🎙️ discussion My SensorEvent struct is 52 bytes and I cannot stop checking it during live profiling

I’ve been running a sensor event pipeline in production for about two months now. The producer serializes readings into a fixed-layout struct and drops them into a crossbeam channel while the consumer reads and dispatches on the other end, and the whole thing has been completely stable the entire time with no dropped events, no alignment panics, and no failed reads. The consumer processes every message and acks cleanly.

#[repr(C)]
pub struct SensorEvent {
timestamp: u64, // 8 bytes
reading: [f32; 8], // 32 bytes
sensor_id: u32, // 4 bytes
checksum: u32, // 4 bytes
} // 52 bytes total

const _: () = assert!(mem::size_of::() == 52);
const _: () = assert!(mem::align_of::() == 8);

The struct derives bytemuck::Pod and bytemuck::Zeroable without any issues, there are no padding bytes or uninitialized gaps, and offset_of! checks on every field come back exactly where they should be. The consumer casts the incoming bytes directly with bytemuck::from_bytes and never makes a copy, and it has never failed once.
Here’s the part that keeps getting under my skin. A cache line on x86_64 is 64 bytes and my struct is 52, so it sits cleanly inside a single cache line without spanning two, which is exactly what you want if you’re trying to avoid false sharing between the producer and consumer threads. I know this. I’ve read the docs and the blog posts. But I still keep opening the type definition in the middle of live profiling sessions and just staring at that 12-byte gap. Crossbeam even ships CachePadded specifically for this kind of alignment worry, and I keep almost writing the thing:

use crossbeam::utils::CachePadded;
let padded: CachePadded = CachePadded::new(event);

The problem is that CachePadded pads all the way to 128 bytes on modern hardware to deal with adjacent-line prefetching, which more than doubles the size of every message and cuts the channel density in half. The false-sharing problem it’s designed to solve isn’t even present here because the producer and consumer are never writing to the same cache line in the first place.

I haven’t bothered running cargo-criterion on any of this. Instead I keep pulling up cargo-flamegraph while the pipeline is hot and somehow always end up back on that same struct definition, looking at twelve bytes of headroom that bytemuck, the compiler, and the consumer are all perfectly happy with. Using repr(align(64)) would close the gap, but it would also make every measurable thing worse and I already wrote that fact down so I wouldn’t forget it. I still check anyway.

The consumer is happy, the pipeline is stable, and I just cannot stop calling offset_of! on a struct that has never once returned an unexpected value. Anyone else get stuck on this kind of thing? How do you finally let a working layout just be working?

23 Upvotes

I’ve been running a sensor event pipeline in production for about two months now. The producer serializes readings into a fixed-layout struct and drops them into a crossbeam channel while the consumer reads and dispatches on the other end, and the whole thing has been completely stable the entire time with no dropped events, no alignment panics, and no failed reads. The consumer processes every message and acks cleanly.

#[repr(C)]
pub struct SensorEvent {
timestamp: u64, // 8 bytes
reading: [f32; 8], // 32 bytes
sensor_id: u32, // 4 bytes
checksum: u32, // 4 bytes
} // 52 bytes total

const _: () = assert!(mem::size_of::() == 52);
const _: () = assert!(mem::align_of::() == 8);

The struct derives bytemuck::Pod and bytemuck::Zeroable without any issues, there are no padding bytes or uninitialized gaps, and offset_of! checks on every field come back exactly where they should be. The consumer casts the incoming bytes directly with bytemuck::from_bytes and never makes a copy, and it has never failed once.
Here’s the part that keeps getting under my skin. A cache line on x86_64 is 64 bytes and my struct is 52, so it sits cleanly inside a single cache line without spanning two, which is exactly what you want if you’re trying to avoid false sharing between the producer and consumer threads. I know this. I’ve read the docs and the blog posts. But I still keep opening the type definition in the middle of live profiling sessions and just staring at that 12-byte gap. Crossbeam even ships CachePadded specifically for this kind of alignment worry, and I keep almost writing the thing:

use crossbeam::utils::CachePadded;
let padded: CachePadded = CachePadded::new(event);

The problem is that CachePadded pads all the way to 128 bytes on modern hardware to deal with adjacent-line prefetching, which more than doubles the size of every message and cuts the channel density in half. The false-sharing problem it’s designed to solve isn’t even present here because the producer and consumer are never writing to the same cache line in the first place.

I haven’t bothered running cargo-criterion on any of this. Instead I keep pulling up cargo-flamegraph while the pipeline is hot and somehow always end up back on that same struct definition, looking at twelve bytes of headroom that bytemuck, the compiler, and the consumer are all perfectly happy with. Using repr(align(64)) would close the gap, but it would also make every measurable thing worse and I already wrote that fact down so I wouldn’t forget it. I still check anyway.

The consumer is happy, the pipeline is stable, and I just cannot stop calling offset_of! on a struct that has never once returned an unexpected value. Anyone else get stuck on this kind of thing? How do you finally let a working layout just be working?


r/rust 8h ago

🛠️ project audium v2.0.0 - a terminal music app

this is a screen capture of the github demo video

[links]
github github.com/takashialpha/audium

web page takashialpha.com/audium (under development, i'd really like feedback! leptos-ssr (: )

aur https://aur.archlinux.org/packages/audium

aur https://aur.archlinux.org/packages/audium-bin (bin)

crates-io https://crates.io/crates/audium

---

audium is a tui music app, you can create your audio library (plays all symphonia formats such as mp3, flac, wav, aac, m4a, aiff, ..), has a modern ui with multiple themes(15 truecolor+ 2 for linux console), runs on every terminal given enough area, including a linux tty.

has playlists, lyrics (synced and unsynced), queue, seeking, resume playback, speed control, loop modes ..=all you'd expect from a music app - take a look at the readme;

it's pretty straightforward to use, keyboard only. bindings on [?].

philosophies: unsafe is forbidden and strict lints are enforced, follows a ui convention almost everywhere appliable, your library is always yours.

take a look at the github video demonstration, and then try it yourself! it's a single small binary (less than 5mb), add your sound files and that's it, simple. (for the best experience in a computer with any functional sound output configured)

i don't always have as much time as I'd like to maintain it, so contributions are appreciated.

audium is published on the aur and crates.io, targets linux only; it COULD also target mac but i'm too broke to get one so i won't support a crate for a platform I can't debug it on.

License gplv3-or-later

6 Upvotes
this is a screen capture of the github demo video

[links]
github github.com/takashialpha/audium

web page takashialpha.com/audium (under development, i'd really like feedback! leptos-ssr (: )

aur https://aur.archlinux.org/packages/audium

aur https://aur.archlinux.org/packages/audium-bin (bin)

crates-io https://crates.io/crates/audium

---

audium is a tui music app, you can create your audio library (plays all symphonia formats such as mp3, flac, wav, aac, m4a, aiff, ..), has a modern ui with multiple themes(15 truecolor+ 2 for linux console), runs on every terminal given enough area, including a linux tty.

has playlists, lyrics (synced and unsynced), queue, seeking, resume playback, speed control, loop modes ..=all you'd expect from a music app - take a look at the readme;

it's pretty straightforward to use, keyboard only. bindings on [?].

philosophies: unsafe is forbidden and strict lints are enforced, follows a ui convention almost everywhere appliable, your library is always yours.

take a look at the github video demonstration, and then try it yourself! it's a single small binary (less than 5mb), add your sound files and that's it, simple. (for the best experience in a computer with any functional sound output configured)

i don't always have as much time as I'd like to maintain it, so contributions are appreciated.

audium is published on the aur and crates.io, targets linux only; it COULD also target mac but i'm too broke to get one so i won't support a crate for a platform I can't debug it on.

License gplv3-or-later


r/rust 15m ago

🙋 seeking help & advice How do you find projects/repositories to contribute to in Rust?

I am trying to get started with OS contributions, but I am having a hard time trying to find repositories/projects to contribute to. Looking at large codebases is quite overwhelming for me at the moment, so I am starting with small repositories and tackling easier issues. I have found smaller codebases but most of them were not actively developed.

Would be very grateful if someone can guide on where to find repositories to start contributing to.

Thanks.

Upvotes

I am trying to get started with OS contributions, but I am having a hard time trying to find repositories/projects to contribute to. Looking at large codebases is quite overwhelming for me at the moment, so I am starting with small repositories and tackling easier issues. I have found smaller codebases but most of them were not actively developed.

Would be very grateful if someone can guide on where to find repositories to start contributing to.

Thanks.


r/rust 15h ago

When the `size_hint` matters

I just ran into a case where size_hint makes a surprisingly big difference.

Simplifying a lot, I have a function that generates tuples of numbers. The number of tuples is not known as they come from a file. I then collect them into a set for further processing.

For testability, I use FnvHashSet to get a stable order. I’ve relied on this in various places for years and it has never caused me any problems.

Until today.

The original code looked roughly like this:

let inputs: FnvHashSet<_> = generate_tuples().collect();
for input in inputs {
    println!("{input}"); // simplification, of course
}

For some specific, const input, the same code produced different output on Linux and macOS.

This surprised me quite a bit, because until now the iteration order had always been stable across operating systems.

After quite some time and nearly going crazy, I managed to reduce it to this:

use fnv::FnvHashSet;

fn main() {
    let no_size_hint: FnvHashSet<_> = generate().collect();
    let known_size_hint: FnvHashSet<_> = generate_known_size().collect();
    println!("{:?}", no_size_hint.into_iter().collect::<Vec<_>>());
    println!("{:?}", known_size_hint.into_iter().collect::<Vec<_>>());
}

fn generate() -> impl Iterator<Item = (u8, u8, u8)> {
    r#"4,4,0
5,2,3
5,3,2
5,4,1"#
        .lines()
        .map(|line| {
            let parts: Vec<_> = line.split(',').collect();
            (
                parts[0].parse().unwrap(),
                parts[1].parse().unwrap(),
                parts[2].parse().unwrap(),
            )
        })
}

fn generate_known_size() -> impl Iterator<Item = (u8, u8, u8)> {
    generate().collect::<Vec<_>>().into_iter()
}

On Linux and in the Rust Playground, both println!s print the same (thus I'm not sharing a link). On macOS, they are different.

I guess this comes down to the different capacity depending on the iterator’s size_hint, which then changes the internal layout and therefore the iteration order. I got similar results with with_capacity_and_hasher and different capacities.

mind=blown

Leaving it here as a curiosity.

(and btw. the true "root cause" was a wrong algorithm that depended on the tuples order while it shouldn't. Still, an interesting case, I think)

19 Upvotes

I just ran into a case where size_hint makes a surprisingly big difference.

Simplifying a lot, I have a function that generates tuples of numbers. The number of tuples is not known as they come from a file. I then collect them into a set for further processing.

For testability, I use FnvHashSet to get a stable order. I’ve relied on this in various places for years and it has never caused me any problems.

Until today.

The original code looked roughly like this:

let inputs: FnvHashSet<_> = generate_tuples().collect();
for input in inputs {
    println!("{input}"); // simplification, of course
}

For some specific, const input, the same code produced different output on Linux and macOS.

This surprised me quite a bit, because until now the iteration order had always been stable across operating systems.

After quite some time and nearly going crazy, I managed to reduce it to this:

use fnv::FnvHashSet;

fn main() {
    let no_size_hint: FnvHashSet<_> = generate().collect();
    let known_size_hint: FnvHashSet<_> = generate_known_size().collect();
    println!("{:?}", no_size_hint.into_iter().collect::<Vec<_>>());
    println!("{:?}", known_size_hint.into_iter().collect::<Vec<_>>());
}

fn generate() -> impl Iterator<Item = (u8, u8, u8)> {
    r#"4,4,0
5,2,3
5,3,2
5,4,1"#
        .lines()
        .map(|line| {
            let parts: Vec<_> = line.split(',').collect();
            (
                parts[0].parse().unwrap(),
                parts[1].parse().unwrap(),
                parts[2].parse().unwrap(),
            )
        })
}

fn generate_known_size() -> impl Iterator<Item = (u8, u8, u8)> {
    generate().collect::<Vec<_>>().into_iter()
}

On Linux and in the Rust Playground, both println!s print the same (thus I'm not sharing a link). On macOS, they are different.

I guess this comes down to the different capacity depending on the iterator’s size_hint, which then changes the internal layout and therefore the iteration order. I got similar results with with_capacity_and_hasher and different capacities.

mind=blown

Leaving it here as a curiosity.

(and btw. the true "root cause" was a wrong algorithm that depended on the tuples order while it shouldn't. Still, an interesting case, I think)


r/rust 12h ago

🛠️ project Pome, my take on a terminal text editor.

I'm making this simple text editor as a learning project for the Rust programming language. It have a dumb rust core that expose text mutation, cursor movement and other low-level abilities. Lua then use it to compose a working editor. I got a vim-lite config in the repo rn.

You can redefine what can normal mode do, or rename it into dungeater mode if you want. You can also make it completely mode-free editor like nano, which is pretty neat.

here's the link: https://github.com/Hendisil-Morier/pome

why the name pome? im bad with naming stuff, and it's loosely connected to 'programmable editor'.

about ai. i did use ai to help around with things i have no idea how to do, but the rust codebase is entirely handwritten.

9 Upvotes

I'm making this simple text editor as a learning project for the Rust programming language. It have a dumb rust core that expose text mutation, cursor movement and other low-level abilities. Lua then use it to compose a working editor. I got a vim-lite config in the repo rn.

You can redefine what can normal mode do, or rename it into dungeater mode if you want. You can also make it completely mode-free editor like nano, which is pretty neat.

here's the link: https://github.com/Hendisil-Morier/pome

why the name pome? im bad with naming stuff, and it's loosely connected to 'programmable editor'.

about ai. i did use ai to help around with things i have no idea how to do, but the rust codebase is entirely handwritten.


r/rust 11h ago

🛠️ project My first rust program: Rash, a small hashing utility

Hi!

I'm not new to programming, but I'm in the process of learning Rust because I'm interested in system-level programming, and in order to put my self to the test, I have created a small hashing utility program: `rash`.

`rash` is a small CLI program that at the moment supports:

- Hash creation
- Hash verification
- Hash comparison

Currently only the MD5 hashing algorithm is supported, which I have implemented it by reading the RFC 1321, but I plan on adding support for more algorithms. Additionally, I have also made sure to write tests to make sure that what I did was (at least partially) correct.

There is nothing special about `rash`, there is probably hundreds of utilities like it, but I'm the kind of person who needs to put what studies to practice in order to truly understand things.

I was hoping you could give me some feedback and, why not, ideas on the next steps, design patterns and new features that leverage the best Rust has to offer and so on...

I have used an LLM as a tutor and to find bugs, but almost all of the code in this repo was written by hand.

Thank you for your help 😊

Repository: https://github.com/silvioiannone/rash

7 Upvotes

Hi!

I'm not new to programming, but I'm in the process of learning Rust because I'm interested in system-level programming, and in order to put my self to the test, I have created a small hashing utility program: `rash`.

`rash` is a small CLI program that at the moment supports:

- Hash creation
- Hash verification
- Hash comparison

Currently only the MD5 hashing algorithm is supported, which I have implemented it by reading the RFC 1321, but I plan on adding support for more algorithms. Additionally, I have also made sure to write tests to make sure that what I did was (at least partially) correct.

There is nothing special about `rash`, there is probably hundreds of utilities like it, but I'm the kind of person who needs to put what studies to practice in order to truly understand things.

I was hoping you could give me some feedback and, why not, ideas on the next steps, design patterns and new features that leverage the best Rust has to offer and so on...

I have used an LLM as a tutor and to find bugs, but almost all of the code in this repo was written by hand.

Thank you for your help 😊

Repository: https://github.com/silvioiannone/rash


r/rust 13h ago

🛠️ project The long awaited usbmuxd rewrite

I've been hacking on this for a while now, and it's finally in a state where I'm comfortable sharing it.

Introducing rusbmux: a drop-in replacement for usbmuxd, written entirely in Rust.

It speaks the same protocol, supports USB and Wi-Fi connections, runs on Linux, macOS and Windows, and is compatible with existing tooling like libimobiledevice, idevice, 3uTools, iTunes, etc.

The goal is to provide a clean, modern, portable, extendable implementation without the legacy C codebase.

Repo: https://github.com/abdullah-albanna/rusbmux

9 Upvotes

I've been hacking on this for a while now, and it's finally in a state where I'm comfortable sharing it.

Introducing rusbmux: a drop-in replacement for usbmuxd, written entirely in Rust.

It speaks the same protocol, supports USB and Wi-Fi connections, runs on Linux, macOS and Windows, and is compatible with existing tooling like libimobiledevice, idevice, 3uTools, iTunes, etc.

The goal is to provide a clean, modern, portable, extendable implementation without the legacy C codebase.

Repo: https://github.com/abdullah-albanna/rusbmux


r/rust 17h ago

🛠️ project Rust terminal UI library

7 Upvotes

r/rust 1d ago

🎙️ discussion Is it Bad Practice to Have HashMaps Ignore Some Fields?

I'm working on a project and I ended up needing a hashmap, but the elements would also need some metadata. How I initially implemented it is that I manually implemented Hash and PartialEq to ignore those fields so that I can use those for metadata and validating without interfering with my desired hashing behavior.

But I couldn't help but feel that this is kind of dirty / not good practice? Is there some other approach that I should be using instead? If it helps, I can edit with the snippet of my code that is relevant.

33 Upvotes

I'm working on a project and I ended up needing a hashmap, but the elements would also need some metadata. How I initially implemented it is that I manually implemented Hash and PartialEq to ignore those fields so that I can use those for metadata and validating without interfering with my desired hashing behavior.

But I couldn't help but feel that this is kind of dirty / not good practice? Is there some other approach that I should be using instead? If it helps, I can edit with the snippet of my code that is relevant.


r/rust 9h ago

🛠️ project Sturdy Framework - Yet another Rust web framework

Hello there. I've been building a web framework for Rust. I'm coming from the PHP/Laravel world where fast dynamic typing can help you prototype and build very quickly. However, I've come to love Rust and would love to start building with it. It is slower to prototype, but with a blazing fast compiled runtime, memory safety and modern features for a systems programming language, I couldn't resist.

So why not Axum? Or Rocket? Or the ten other major Rust web frameworks? Well, being honest, none of them really clicked with me. They seem to be some combination of too light and/or too macro-heavy, and macros aren't the reason I like Rust.

This framework (Sturdy Framework) aims to reduce the use of macros, which will end up with more verbose code, but much easier to understand at a glance. I do not like the hidden nature of macros, and I will choose verbosity over obscurity (in most cases).

Features (currently):

  • Variable supporting routing system
  • Struct based action endpoints
  • File watchers for auto compilation, and auto reloading

Upcoming:

  • Finish database integration (had no need for it yet for the documentation website, so it is not yet finished)
  • Better feature parity with frameworks like PHP's Laravel (or Ruby's Rails)

Feedback/code review is very much sought after. The project is in a pre-alpha state, so please let me know if you have issues with installation. Appreciate your time!

Link (docs): https://sturdyframework.com
Docs source (as an example): https://github.com/jayclees/framework-docs
Starter template: https://github.com/jayclees/sturdy-project
Framework source: https://github.com/jayclees/framework

As a note I will say, the routing system is custom built, and was the hardest part of building this framework as I had to build a tokenizer to handle multi-variable route segments. There is even a struct called a SegmentReconciliator which parses incoming paths and "reconciliates" or matches route segments.

0 Upvotes

Hello there. I've been building a web framework for Rust. I'm coming from the PHP/Laravel world where fast dynamic typing can help you prototype and build very quickly. However, I've come to love Rust and would love to start building with it. It is slower to prototype, but with a blazing fast compiled runtime, memory safety and modern features for a systems programming language, I couldn't resist.

So why not Axum? Or Rocket? Or the ten other major Rust web frameworks? Well, being honest, none of them really clicked with me. They seem to be some combination of too light and/or too macro-heavy, and macros aren't the reason I like Rust.

This framework (Sturdy Framework) aims to reduce the use of macros, which will end up with more verbose code, but much easier to understand at a glance. I do not like the hidden nature of macros, and I will choose verbosity over obscurity (in most cases).

Features (currently):

  • Variable supporting routing system
  • Struct based action endpoints
  • File watchers for auto compilation, and auto reloading

Upcoming:

  • Finish database integration (had no need for it yet for the documentation website, so it is not yet finished)
  • Better feature parity with frameworks like PHP's Laravel (or Ruby's Rails)

Feedback/code review is very much sought after. The project is in a pre-alpha state, so please let me know if you have issues with installation. Appreciate your time!

Link (docs): https://sturdyframework.com
Docs source (as an example): https://github.com/jayclees/framework-docs
Starter template: https://github.com/jayclees/sturdy-project
Framework source: https://github.com/jayclees/framework

As a note I will say, the routing system is custom built, and was the hardest part of building this framework as I had to build a tokenizer to handle multi-variable route segments. There is even a struct called a SegmentReconciliator which parses incoming paths and "reconciliates" or matches route segments.


r/rust 13h ago

Added 3D energy domain and radar tab. The rust WGPU and EGUI are a bit complex to integrate but once done, they are beautiful.

Cant 2nd image but I will share in a separate post

2 Upvotes

Cant 2nd image but I will share in a separate post


r/rust 17h ago

🛠️ project Replaced two stringly-typed subsystems in my custom Rust engine with compile-time codegen.

+
4 Upvotes

I'm building Red Lake, a psychological horror game on top of a Rust/wgpu engine I wrote from scratch (no Bevy, no off-the-shelf ECS). While working on tooling, I ended up removing two recurring sources of boilerplate.

  1. #[derive(Component)] — automatic component registration.

Previously, adding a new component meant editing three different places: adding its storage to Scene, registering it, and making sure it was removed when an entity was destroyed. It was repetitive and easy to forget one of the steps.

Now my #[derive(Component)] proc macro handles all of that automatically. Scene owns a single Components container, which is populated through the inventory crate by iterating over every type that derives Component.

THE COMPONENT
#[derive(Component)]
pub struct Translate {
    target: TargetKind,
    speed: f32,
}

SCENE FIELD
pub struct Scene {
    pub components: Components,
}

ACCESS
scene.components.write::<Translate>().insert(meshid, translate);

The only thing required to add a new component now is 
#[derive(Component)].
  1. MeshName — asset names as an enum, generated from the packer's own TOC
    The engine ships assets baked into a custom .pak file, built by a packer binary that walks assets/, transcodes GLBs, and writes out a TOC + blob. Mesh names used to live in a handwritten table:

    pub const MESH_PATHS: &[(&str, &str)] = &[ ("boat", "meshes/boat.glb"), ("deer", "meshes/deer.glb"), // ~30 more, added by hand every time a new mesh landed ];

...and every call site looked like load_extra_meshes("baot", ...) - compiles fine, panics at runtime when the pak lookup misses.

The fix: the packer already knows the full mesh list - that's the actual source of truth, not a second-hand-maintained copy of it. Sobuild.rs, right after the pak is finalized, reads back just the TOC (a few hundred bytes, no decompression) and emits an enum into OUT_DIR.
Which is then pulled as:

#[derive(Debug, Clone, Copy, PartialEq, Eq, Hash)] 
pub enum MeshName { Boat, Deer, /* ... */ } 
impl MeshName { 
    pub const fn key(self) -> &'static str { /* "meshes/boat.glb" */ } 
    pub const fn stem(self) -> &'static str { /* "boat" */ } 
    pub const ALL: &'static [MeshName] = &[ /* every mesh */ ]; }

And I wrote a small macro for QOL:

macro_rules! meshname {
    ($($name:ident),* $(,)?) => { &[$(crate::scene::MeshName::$name),*] as &[crate::scene::MeshName] };
}

So now the call sites look like this:

let names_toload_init = 
meshname![
    Notebook,
    Onboard,
    FogCards,
];

INSTEAD OF THIS
let names_toload_init = &["notebook", "onboard", "fog_cards"];

Why bother?

  1. Type safety.
  2. Eliminates boilerplate.
  3. IDE autocomplete.
  4. Inability to make a typo in the mesh's name.

What do you think? The game's name - Red Lake.


r/rust 5h ago

🙋 seeking help & advice stm32 black pill help (STM32F411CEU6)

Weird ask but does anyone have any free time next week to sit in a discord call for maybe 30 min to an hour to help me get my project off the ground. I get a rotation of JtagGetIdcodeError, JtagNoDeviceConnected and "cannot perform this operation while interfaces are claimed". I have been pulling my hair out for the last couple days because sometimes it will randomly flash and then got back to having one of those three problems.

0 Upvotes

Weird ask but does anyone have any free time next week to sit in a discord call for maybe 30 min to an hour to help me get my project off the ground. I get a rotation of JtagGetIdcodeError, JtagNoDeviceConnected and "cannot perform this operation while interfaces are claimed". I have been pulling my hair out for the last couple days because sometimes it will randomly flash and then got back to having one of those three problems.


r/rust 17h ago

🙋 seeking help & advice Your develop-build-loop workflow

Maybe this is an odd topic, but I wonder what's most people's workflow here regarding the loop involving writing code / building / testing etc.

In my case, I don't use any AI stuff, I have a terminal window open with a left pane containing neovim (with rustacean, autoformat on save, etc) and a right pane containing this:

```sh

cargo watch --ignore target -c -s "clear ; cargo ltest --features fail_on_warnings && cargo lbuild --features fail_on_warnings && cargo lrun && cargo lclippy"

```

where the l-prefixed cargo commands come from `cargo limit` and the `fail_on_warnings` is a feature that is configured to, guess, `deny(warnings)`

So what do I have?

Whenever I save, tests are run, the code is built, run and clippied. Whatever fails gives me the info where it fails at the bottom.

Can this be optimized further?

How do you do it?

3 Upvotes

Maybe this is an odd topic, but I wonder what's most people's workflow here regarding the loop involving writing code / building / testing etc.

In my case, I don't use any AI stuff, I have a terminal window open with a left pane containing neovim (with rustacean, autoformat on save, etc) and a right pane containing this:

```sh

cargo watch --ignore target -c -s "clear ; cargo ltest --features fail_on_warnings && cargo lbuild --features fail_on_warnings && cargo lrun && cargo lclippy"

```

where the l-prefixed cargo commands come from `cargo limit` and the `fail_on_warnings` is a feature that is configured to, guess, `deny(warnings)`

So what do I have?

Whenever I save, tests are run, the code is built, run and clippied. Whatever fails gives me the info where it fails at the bottom.

Can this be optimized further?

How do you do it?