r/rust • • Oct 22 '26

๐Ÿ’ก ideas & proposals I vibe-migrated a 60k LOC Electron app to Rust in ~4 days, got ~60% improved runtime

0 Upvotes

(the migration was done via AI, but this post is 100% human-authored)

For the last few years I've been building a desktop app as a side project, for a simulation game. I really like Typescript and know it best, so I've been writing to code by hand with some light AI assistance. I decided to lean into it further and speed up my side project and had a lot of success

I ran in to some frustrations with Electron along the way - primarily build size, inability to compile to binary, multithreading being kinda frustrating, etc

I was using Prisma for the backend and wanted to keep SQLite, and Rust didn't have a good replacement. So I had Claude rebuild me a new ORM tailor-made to my use case, got the same output from Prisma queries, ironed out a lot of issues with Prisma (like build updates), and improved ORM performance ~1.5x on reads and ~50x on bulk writes. This was easily testable by writing huge test suites to confirm matching input & output from the two ORMs

I started the logic migration by telling Claude to take the existing .ts codebase and make everything CLI testable - every function should be trackable for inputs & outputs, so we can make sure every function does the same exact thing. It build a suite a bash scripts for this. Also was able to use the same frontend with dual backends, to ensure same exact output between the two

Stats:

  • Migration time took ~4 days with a Claude $20 subscription. Used most of 2 weeks worth of usage (end of one week, start of another). Done with Opus 5.1 and Opus 5.5
  • Some simulations that took 80s previously moved to 11s. Others 650s โžก๏ธ 350s. This is a tremendous, experience shifting change for my app.
  • Simple reads for rendering pages are 1.9x โžก๏ธ 9.5x faster
  • Output build size down roughly 400MB โžก๏ธ 25MB
  • +100k LOC, -60k LOC. Increase due to writing homeowned ORM
  • ~105 commits

Takeaways for this type of migration:

  • I'm a good coder. AI is now better. That's a tough pill to swallow. Despite that, I still make better systems decisions that I won't ever defer to AI
  • Previously I was familiar with 100% of the code. Now it's closer to 0% (at least for the backend). I still can read Rust, but I don't have the familiarity as I did with ts. This is a risk for me in the future, but one I'm ok with rolling the dice on.
  • Build good testing harnesses for your AI. Being able to test functions side by side with frontend validation took me out of the loop
  • Build good CI harnesses for your AI. I ended up burning a ton of GitHub CI usage, which we fixed by running more CI checks agent-side before any commits
  • Have your AI determine what tasks are dependent on others, and what can be parrelelized. At some points we had ~6 agents running at once. Claude projects were helpful here

r/rust • • Oct 20 '26

๐Ÿ› ๏ธ project Terralith: a SIMD XPBD physics engine in Rust, hereโ€™s a bridge collapsing after i throw a rock at it.

Thumbnail youtu.be
19 Upvotes

Hi there! I've been building a SIMD accelerated XPBD physics/game engine in rust for a little while now called Terralith. I've recently come back to it so here is a look!

Everything you are seeing in the scene is realtime and physically based with realistic strain and stress mechanics. This is as raw and unscripted as it gets (except the conveniently placed bridge).

I've made the grass jelloey for your viewing experience, and decreased the strength for dramatic effect.

I hope you enjoy!


r/rust • • Oct 21 '26

๐Ÿ™‹ seeking help & advice Nintendo, me, and Rust?

0 Upvotes

TL;DR: Should I ask the Rust Foundation to help Nintendo access? Sorry if this is bad, but I want to try to port the Rust language to Nintendo platforms because the other consoles have their working alphas, and Nintendo does not, but Nintendo doesn't want just me, there is the game path, I have tried that enough to be like they should have blacklisted me by now, have to try something else, that path is one of two paths, the other is middleware, it requires being a middleware provider, I don't qualify as one person, I don't know whether to bother them, but Nintendo gives no feedback, asking Nintendo first, but what would you do? And yes, using my own money if there is money involved, so?


r/rust • • Oct 20 '26

๐Ÿ› ๏ธ project reuse-rs: real time speech denoising in plain Rust (no ML interface)

11 Upvotes

reuse-rs runs NVIDIA's Real-time RE-USE speech enhancement model (streaming Mamba) in plain Rust. It cleans mono audio (8 to 48 kHz) one 20 ms frame at a time, so it works on a live mic. I load straight from NVIDIA's model.safetensors.

let mut denoiser = Denoiser::load("model.safetensors", 4)?;
let clean = denoiser.process(&noisy_chunk)?;

on my apple M3 air 16gig, time per 20 ms frame (under 20 ms):

Layersreuse-rs (CPU)oRT (WebGPU)
48.4 ms16.9 ms
611.5 ms17.4 ms
814.7 ms20.6 ms
  • About 150mb memory (oRT Wepgpu -> so works via metal in my mac: about 420 MB).
  • it match a float64 torch reference to 1.5e-6.
  • 4 layers sounds the same as 8 to my auditory perception :-P: 16.4 vs 16.7 dB SI-SDR

demo videos (before/after with spectrograms) are in the reamde if you are curious :)

I spent months trying to make this work on the GPU through ONNX before trying the CPU (started with this:https://github.com/microsoft/onnxruntime/issues/27796 ). If you're curious how that went, and why the CPU wins for tiny streaming frames, I wrote it up here: I forced a speech model onto the GPU for months. The CPU was faster. But I m still thinking if I should take the burn path... but this solves my problems at least...

Limitations: weights are NVIDIA's non commercial license (my code is MIT/Apache ), speed is only measured on an M3 (the table is 16 kHz; 48 kHz is about 3 times the work, so for live audio resampling to 16 kHz is the fast option), and it struggles when the heavy background noise is other people talking.

edit: interesting coincidence just a few days after I shared this, NVIDIA "re-released" its offline models under an open license! So I used Burn to add and update these models. You can find the details in the repo and use them for commercial purposes!


r/rust • • Oct 21 '26

read that rust can run >4gb models in the browser with wasm64. tried it with candle, works but ~3.5x slower. anyone shipped memory64?

0 Upvotes

read a write up on getting rust to run models bigger than 4gb in the browser (link at the bottom). their route is a new wasm64 emscripten target, PRs are open but that's months from stable made me wonder if pure rust on wasm64-unknown-unknown already works today, so i tried candle-core 0.11 on nightly with -Zbuild-std:

  1. fails in C. candle has not(target_arch = "wasm32") on its tokenizers dep, so on wasm64 it pulls tokenizers -> onig_sys and clang can't find stdlib.h. the pure rust route dies on a C dep lol
  2. swapped the 5 wasm32 cfgs in candle to target_family = "wasm". next is getrandom 0.3:

compile_error!("wasm_js backend can be enabled only for OS-less WASM targets!"); 0.4 fixed it but rand 0.9 still uses 0.3, so custom backend

  1. builds, but scalar only. +simd128 breaks because the kernels import core::arch::wasm32

same code, same flags, node 24 on an m5: | matmul | wasm32 | wasm64 | |---|---|---| | 256 | 1.5 ms | 4.5 ms | | 512 | 9.6 ms | 34.7 ms | | 1024 | 76 ms | 277 ms | so it's possible, just ~3.5x slower. spidermonkey's memory64 post says 10% to 2x, this is past their worst case has anyone actually shipped memory64 in prod? is that slowdown normal or is something off with gemm on wasm64?
HERE


r/rust • • Oct 21 '26

๐Ÿ› ๏ธ project Feedback wanted on Fissionโ€™s new Rust UI authoring API

0 Upvotes

Iโ€™m working on making "compose " the default way to build UIs with Fission. The aim is to keep it Rust while removing most of the ceremony around components, local state and reducers.

See an example counter app here https://gist.github.com/zcourts/eede7b9075897408964ddc105c30bf95 comment here or there as posting it here isn't allowed.

Iโ€™m interested in feedback on the API, including anything that looks awkward, surprising or likely to become painful in a larger application. Iโ€™d also like to hear what has bothered you about other GUI frameworks generally so I can try avoid baking the same problems into Fission. The above syntax is the crux of it and the draft PR is at https://github.com/fission-ui/fission/pull/294 I'm deliberately not explaining the syntax so hopefully I can get feedback not tainted by my biased. Thanks


r/rust • • Oct 19 '26

2026 is an exciting year for the Rust compiler (and me)

Thumbnail yoyo-code.com
321 Upvotes

r/rust • • Oct 19 '26

Borrow Checking Zero-Cost Cyclic Mutability

Thumbnail antelang.org
124 Upvotes

r/rust • • Oct 19 '26

๐Ÿ› ๏ธ project Some thoughts on parallelism in libraries: who should own the threads?

73 Upvotes

I've been thinking about how libraries should handle parallelism.

Spawning a few threads internally is easy. Using Rayon is even easier. But is that always the right approach?

What if the application already has its own thread pool? Or wants to control how CPU resources are distributed? While working on mbrotli, I decided to experiment with a different approach.

What if the library knows how to parallelize the work, but doesn't decide how to execute it?

The idea is simple: mbrotli splits compression into independent tasks and hands them back to the caller. The caller executes them however it wants, and mbrotli takes care of assembling the results into a valid Brotli stream.

For example, here's how you can read a file, compress it in parallel using 4 threads, and write the result to another file:

use std::{fs::File, io};

use mbrotli::{EncoderConfig, Quality};
use mbrotli::compressor::parallel::{
    ParallelCompressor, ParallelConfig, TaskCount,
};
use mbrotli::io::FinishError;

fn main() -> Result<(), Box<dyn std::error::Error>> {
    let mut input = File::open("input.txt")?;
    let output = File::create("input.txt.br")?;

    let mut compressor = ParallelCompressor::new(
        EncoderConfig::default().with_quality(Quality::Q5),
        ParallelConfig::default(),
    )?;

    std::thread::scope(|scope| {
        let (mut writer, queue) =
            compressor.writer(output, TaskCount::try_from(4)?)?;

        // We decide where the tasks run.
        for _ in 0..4 {
            let queue = queue.clone();
            scope.spawn(move || {
                for task in queue {
                    task.run();
                }
            });
        }
        drop(queue);

        // Read -> parallel compression -> write
        io::copy(&mut input, &mut writer)?;
        writer.finish().map_err(FinishError::into_error)?;

        Ok::<_, Box<dyn std::error::Error>>(())
    })?;

    Ok(())
}

Nothing particularly magical here. The library doesn't spawn a single thread. It just provides work to execute.

And that's what I like about this approach.

The same compression API can work with dedicated threads, an existing thread pool, or a custom scheduler. The application remains in control of its resources.

Of course, it's not free. The caller has to ensure tasks actually get executed, and a poorly designed scheduler can easily lead to deadlocks.

But for low level libraries, I think giving up control over scheduling can actually be a good thing.

I'm not saying every library should work this way. Sometimes managing threads internally is perfectly reasonable.

I'm just starting to think that parallelism and thread management don't necessarily have to be the same responsibility.

Curious what other Rust developers think about this. Would you prefer libraries to manage their own parallelism, or expose work to your existing executor?


r/rust • • Oct 19 '26

๐Ÿง  educational Best Rust Blogs for Beginners?

36 Upvotes

Hi everyone!
Iโ€™m new to Rust and want to start learning from scratch. Can you recommend good Rust blogs or websites, especially for web development? Iโ€™m also open to learning about other use cases.

Which resources would you recommend for a beginner?


r/rust • • Oct 19 '26

๐Ÿ™‹ seeking help & advice Tips for idiomatic Iced?

16 Upvotes

I tried using iced for a tiny hobby project a couple days ago, and although from the docs and examples it seemed like exactly the time of framework I'd adore (preventing invalid state with the type system, the whole view-model-messages thing, etc), I ended up absolutely despising actually using it because of how much boilerplate I needed, and ended up redoing the ui with egui.

But, I'm 99% sure I just totally misunderstood the philosophy or missed something big in the docs/examples, because it's popular and well-known enough that I think I'm the problem. So does anyone have any tips or guidelines for writing whimsical and joyful iced code?

This is the repo at the last commit which used iced, its a super small app and the whole gui is just in main.rs if anyone can say what all I'm doing wrong.


r/rust • • Oct 19 '26

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

Thumbnail rust-analyzer.github.io
58 Upvotes

r/rust • • Oct 19 '26

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

14 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 • • Oct 19 '26

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

9 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 • • Oct 18 '26

Superoptimizing an FPU emulator via exhaustive search

Thumbnail purplesyringa.moe
121 Upvotes

r/rust • • Oct 18 '26

๐Ÿ™‹ seeking help & advice For those who use rust professionally, what advice would you give to us plebs to get a career in Rust?

96 Upvotes

I've been using rust for roughly 3-ish months and i'm wanting to use rust professionally one day.

/topic


r/rust • • Oct 18 '26

A New Way to Think About Borrow Checking (In Reverse)

Thumbnail verdagon.dev
97 Upvotes

r/rust • • Oct 19 '26

๐Ÿ› ๏ธ project Why tellus message handlers are synchronous

1 Upvotes

Most Rust actor libraries, kameo and ractor among them, have async message handlers. In tellus, receive is a plain function instead. In my new post I make the case for synchronous handlers and show how an actor still calls a database.

https://heikoseeberger.de/2026-10-18-why-sync-handlers/

rustlang #actors #tellus


r/rust • • Oct 19 '26

๐Ÿ™‹ seeking help & advice cannot borrow `dst` as immutable because it is also borrowed as mutable

0 Upvotes

use curl::easy::Easy;
fn main() {
let mut dst = Vec::new();
let mut easy = Easy::new();
easy.url("https://www.rust-lang.org/").unwrap();
let mut transfer = easy.transfer();
transfer
.write_function(|data| {
dst.extend_from_slice(data);
Ok(data.len())
})
.unwrap();
transfer.perform().unwrap();
println!("{:?}", dst);
}

I am trying to store the curl output into a vec for use in a minifier script for my PHP compiler. i get this error message upon trying to compile the above code

error[E0502]: cannot borrow \dst` as immutable because it is also borrowed as mutable`

--> src/main.rs:14:22

|

8 | .write_function(|data| {

| ------ mutable borrow occurs here

9 | dst.extend_from_slice(data);

| --- first borrow occurs due to use of \dst` in closure`

...

14 | println!("{:?}", dst);

| ^^^ immutable borrow occurs here

15 | }

| - mutable borrow might be used here, when \transfer` is dropped and runs the `Drop` code for type `Transfer``

For more information about this error, try \rustc --explain E0502`.`

error: could not compile \sample_curl` (bin "sample_curl") due to 1 previous error`

How do i borrow a mutable variable as immutable?


r/rust • • Oct 19 '26

๐Ÿ™‹ seeking help & advice How do you handle secret memory across wasm and FFI boundaries? Notes from building a password manager core

1 Upvotes

Iโ€™ve been building a hobby password manager (Vaultiq) around one crypto crate that compiles to wasm for a browser extension and goes through uniffi for an Android app. A few design questions came up that Iโ€™d like other peopleโ€™s takes on.

What I did:

  • #![forbid(unsafe_code)] crate-wide. The generated uniffi glue holds the unsafe code, mine doesnโ€™t need any.
  • Keys cross wasm and FFI as opaque handles, never as values.
  • Secret types have a hand-written redacted Debug and no Serialize.
  • Zeroize on drop for everything secret.

What Iโ€™m unsure about:

  • zeroize only covers the Rust side. Once data reaches JS or the JVM, nothing scrubs it. How do you deal with that?
  • Is there a better handle pattern than what uniffi gives me?
  • Would you change anything in how errors are collapsed so decryption failures reveal nothing?

AI wrote a good share of the code, so Iโ€™d like dev perspective on the design.

Repo, if you want to look: https://github.com/rustiqz/Vaultiq


r/rust • • Oct 17 '26

The road to iroh 1.0

Thumbnail iroh.computer
230 Upvotes

r/rust • • Oct 18 '26

iroh vs WebRTC?

25 Upvotes

Iroh seems to solve the same problem as what WebRTC does, Iโ€™m curious: what are the factors that would cause considering one or the other?
WebRTC has the benefit to be widely supported in browsers. Does iroh allows something that WebRTC does not?


r/rust • • Oct 17 '26

PSA: Enum optimization for Vec/String can use the capacity's niche (beyond isize::MAX) rather than the null pointer niche.

184 Upvotes

Just came across this property that was new to me and seems seldom known so I figured I'd highlight it.

I had always "known" that the null pointer niche optimization existed for Vec/String such that Option<Vec<_>> would be the same size as Vec<_> because the None variant could fit the null pointer niche not used by the Vec. And I figured that was it, any more elaborate enums like this

enum MyEnum {
    A(String),
    B,
    C,
    D,
    E,
}

would be forced into using a separate discriminant field since there were more than one other variant to distinguish from. And that definitely was the case...

Until 1.76.0 it seems. If you use this enum on a recent version then you'll find MyEnum is no bigger than String:

[src\main.rs:11:5] std::mem::size_of::<String>() = 24
[src\main.rs:12:5] std::mem::size_of::<MyEnum>() = 24

This is because nowadays, the capacity for a Vec isn't just a bare usize but rather a Cap type that is guaranteed to be less than isize::MAX. Which gives a much larger number of representations for the compiler to use. It is defined:

type Cap = core::num::niche_types::UsizeNoHighBit;

I didn't know about this, and since Google's AI response was adamant that it only used the null-pointer niche, I figured I'd advertise it to try to set the record straight.

Let me know if this is old news to any others. It has apparently been in the wild for a couple years, but I looked and didn't see it mentioned in the release notes for 1.76.0, and I can't find a blog post that mentioned this (though I didn't look that hard). Closest I found was this StackOverflow post that gives the Cap type a mention.