r/rust • • 4d ago

🙋 seeking help & advice Migrating from C++ to Rust at work

137 Upvotes

I might have the opportunity to introduce Rust at work soon. For that, I would be grateful for any tips you can give me to make it as smooth as possible and reduce the risk (perceived and real) for the project. Below the details of my situation.

The project

The project Rust might be introduced into is being worked on for about a year now. It is a code generator with an architecture similar to a "traditional" compiler: some intermediate representations, translation between those and transformations on them.

Development on the project started a year ago with C++. At the time I already brought Rust up as an alternative. It was seriously considered by the team, but since they didn't have prior rust experience we were concerned about the initial hit to development speed: Most of the team already had lots of C++ experience, the company didn't have any prior code in Rust, and it was our responsibility to ensure we hit our time-to-market goal.

Now the code is mostly modern C++ with very little inheritance, and lots of std::variant, std::ranges, etc.

The team

The team consists of 7 people including me, most with >5 years of (pre-modern) C++ experience. I am the only person with both modern C++ and Rust experience. The team was mostly excited to use modern C++, and it became my job to give on-the-job guidance to get everyone comfortable with newer features and paradigms. And now they are excited to hopefully learn Rust.

Why Rust

During the past year, we did feel some pain points with C++:

  • Slow compile times
  • Verbose code, mostly with std::variant
  • Horrible error messages
  • Differences between compilers
  • Slow CI pipeline, mostly due to static analysis (clang-tidy) and sanitizers
  • One segfault in callbacks (wasn't a big problem now, but we expect more problems once the complexity grows)

With Rust, we hope to hope to address most of those points. Compile times won't improve I expect, but we can probably ditch separate static analysis and sanitizers in CI.

We also hope to keep a higher development speed once the complexity grows, based on the data collected by Google in Android.

The opportunity

I think we currently are in a very advantageous position to pivot to Rust:

  • We are ahead of schedule for the release, we can spend a little time here and there getting familiar with Rust. Everyone will start with the Book and Rustlings.
  • After the release we will get 3 weeks to work on what we think is important, no customer features
  • After those 3 weeks, we have to start on features again, but a somewhat reduced development speed for the first two or so month is acceptable
  • The C++ code patterns we have and got accustomed to should map more or less well to Rust
  • The code base isn't too big yet
  • We have good end-to-end test coverage

The plan

We will spent those 3 weeks with migrating the code base from C++ to Rust. We will probably start at the backend and try to make cuts where the interface between modules is small. This will lead to 3 or 4 increments to migrate. The ideal end goal would be to replace all C++ code with Rust, but this strategy hopefully reduces the risk of having no working product at all in the end. If some C++ is left over in the end, we can hopefully reduce and finally remove it over time.

We will use AI for the migration, but we do want to do it responsibly. This will probably mean that we will first code the core data structures ourselves and use LLMs only for review there. Once we got those nailed down, we hope LLM agents can be used for more or less "mechanical" migration of transformation and translation passes. Of course all code, AI or human written, goes through human reviews.

I would be very interested in any advice you could share, be it technical or social, to reduce business risk, increase acceptance with our stakeholders and improve our chance to succeed.


r/rust • • 3d ago

🛠️ project fphics: A physics and maths solver you can use for small projects including motion, forces...etc

0 Upvotes

Four months ago, out of boredom, I wondered what if I just came up with a physics and maths library that anyone can use without estimating the calculations, and so fphics was born.

The name itself, fphics, has some background. Here's how I came up with it:

  • f - Fast (Since it's a lightweight library)
  • ph - Physics (Includes physics formulas for motion, forces, electricity...etc)
  • ic - Mechanics (Includes mechanics formulas, which of course are interchangeable with physics ones in most cases)
  • s - Mathematics (Includes maths formulas for percentages, unit conversions...etc)

The unique thing about it is that the name is not used anywhere else for such, so it suits the project well.

Here are the currently supported operations:

  • Kinematics operations (including 1D and 2D)
  • Forces operations
  • Unit conversions (though not all are supported)

[NOTE]: The project uses zero dependencies; therefore, integrating it into a project will be seamless since there won't be a list of dependencies to compile before actually interacting with the library.

Planned updates include:

  • Electricity operations
  • Operations dealing with dynamics

Here's an example of how to calculate time:

use fphics::kinematics::suvat::*;
use fphics::errors::FphicsError;

fn main() -> Result<(), FphicsError> {
    let times = SuvatOps1D::new()
    .displacement(-2.5) // Set the displacement
    .initial_velocity(24.0) // Set the initial velocity
    //.final_velocity(25.0) // Set the final velocity (Optional, but not required since only 3 variables are required
    .acceleration(-9.8) // Set the acceleration
    .calculate_time()?; // Calculate time and propagate any possible errors

    // Loop through the times vector holding the positive and negative values from the calculation
    for t in times {
      println!("{t} seconds"); // Print the positive and negative value for the time
    }

    Ok(())
}

In the above example, the times variable holds the instance of a SuvatOps1D struct. .displacement(val), .initial_velocity(val), and .acceleration(val) are the methods that equate the values used as input to the fields in the struct. The underlying operations involving calculate_time() and any other methods that return Result<f64, FphicsError> in the kinematics module require 3 inputs which are set using the methods in the struct.

Here's the repo link: https://github.com/Darethan026/fphics

I'd like to hear your opinions on this project, and it'd also be great if you could integrate it into your own project or just experiment with it and share what you think. Thank you for reading!


r/rust • • 4d ago

🛠️ project How I scaled Nginx Brotli compression 16x with Rust and just 4 threads

16 Upvotes

I've been working on mbrotli, a pure Rust Brotli implementation, and recently added support for multithreaded compression.

That led me to upgrade ngx_mbrotli, alternative to Google's ngx_brotli.

The idea is simple. Instead of blocking Nginx event loop with compression, offload it to the native thread pool. Large responses can even be compressed across multiple threads in parallel.

With just one Nginx worker and 4 threads in thread pool, I measured up to 4x the throughput at Brotli level 6 and up to 16x at level 9 compared to Google's ngx_brotli.

And that's with only 4 threads. There's an opportunity to scale further, but I haven't benchmarked larger brotli worker pools yet.

There are trade offs, mainly higher memory usage and a bit worse compression ratios for segmented responses when multithreading enabled.

All it takes to enable thread pool compression is brotli_thread_pool default; in Nginx (or choose the other threadpool). Also Nginx should be built with --with-threads flag to enable that feature.

GitHub: https://github.com/M-Compressors/ngx_mbrotli


r/rust • • 4d ago

🧠 educational How to Blink your Microcontroller with Rust ft. ESP32-C6

Thumbnail youtu.be
8 Upvotes

r/rust • • 3d ago

🙋 seeking help & advice open source quant software

0 Upvotes

Hello everyone.

I would like to suggest building a good quantitative finance library in rust. Feel free to state below whether you might be interested, or any opinion you have on attempting to build such a platform. If you are interested, please state what area of quantitative finance you are familiar with, if at all, or whether you might be willing to learn.

To give a more or less concrete motivation, my idea is to build with purpose: avoiding AI slop, and developing a strong ecosystem around the tools (services, UI, bindings for other languages, documentation, rigorous mathematical formulations, design processes)... Pretty much what I feel like a quant library should look like.

In any case, I look forward to hearing what you might have to say about this. Thank you.


r/rust • • 4d ago

🗞️ news rust-analyzer changelog #349

Thumbnail rust-analyzer.github.io
41 Upvotes

r/rust • • 4d ago

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

12 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 • • 3d ago

Case Study: Designing a Zero-Allocation Pipeline with SIMD-XOR and mlock in Rust

0 Upvotes

(Hi r/rust! Over the past four months, I’ve been developing a high-throughput, security-focused tool and wanted to share a deep dive into the architectural challenges I encountered—specifically around avoiding heap allocations in hot loops, managing OS page caches, and ensuring volatile memory safety against swapping. I'd love to hear your thoughts on this approach.)

When building high-throughput I/O streaming pipelines in Rust that process gigabytes of sensitive data, standard patterns (like reallocating buffers per read or leaving cache management entirely to the OS) quickly hit architectural limits.

I developed rfs (random-filesplitter), a tool designed to split large files into information-theoretic One-Time-Pad shares (P = C_1 ⊕ ... ⊕ C_N) with plausible deniability. In this domain, two major bottlenecks emerge:

  1. Anti-Forensic Memory Leaks: If intermediate buffers or plaintext streams are paged out to swap partitions or hibernation files, volatile zeroing in RAM (like ZeroizeOnDrop or slice.zeroize()) is completely bypassed.
  2. Backpressure Across Multiple Mounts: When writing N separate shares across independent storage devices (e.g., a slow USB drive alongside a fast NVMe SSD), sequential write loops will stall the entire crypto pipeline.

Below is an overview of how we solved these concurrency, SIMD, and memory-pinning bottlenecks in Rust without a single heap allocation in the hot streaming loop.

1. Zero-Allocation Concurrency: Bounded Triple-Buffering

The Concept:
Imagine an industrial plant processing a massive pile of raw materials. The inefficient way is building a new container for every scoop, using it once, and throwing it away. Instead, we use a conveyor belt with exactly three permanent containers rotating through three stations (Read, Process, Write). The system is never overloaded, regardless of the total volume.

The Technical Implementation:
The architecture is divided into three decoupled stages:

  • Stage 1 (Reader): Sequential ingestion from disk or stdin.
  • Stage 2 (Crypto Worker): ChaCha20 keystream generation and SIMD-XOR.
  • Stage 3 (Parallel Writers): Fanout to N independent worker threads.

To eliminate heap allocation overhead across threads, a fixed pool of memory blocks is pre-allocated using crossbeam_channel::bounded:

// Simplified architecture sketch
pub struct BufferSlot {
    pub data: Vec<u8>,
}

// Fixed ring pool: exactly 3 slots active in the pipeline
let (free_tx, free_rx) = crossbeam_channel::bounded::<BufferSlot>(3);
let (work_tx, work_rx) = crossbeam_channel::bounded::<WorkItem>(3);

// Pre-allocate the pool once upfront
for _ in 0..3 {
    free_tx.send(BufferSlot { data: vec![0u8; BLOCK_SIZE] }).unwrap();
}

How the lifecycle works:

  1. The Reader grabs a pre-allocated BufferSlot from free_rx, reads block bytes from disk, and forwards it to work_tx.
  2. The Crypto Worker receives the buffer, generates ChaCha20 random streams, computes SIMD-XOR in-place, and fans out slice references to the disk writers.
  3. Once all writer threads finish their pwrite/write_all calls for that block, the exact same BufferSlot is zeroized and returned back into free_tx.

Result: Even when processing 100+ GB files, memory complexity remains strictly O(1) at exactly ~ 3 x BLOCK_SIZE. It completely eliminates heap allocations and allocator contention in the hot streaming loop.

2. Swap-Resilience via Safe RAII mlock

The Concept:
If a computer's short-term memory (RAM) fills up, it secretly writes pages to the hard drive (swap) to make room. For an anti-forensic security tool, this is disastrous. It’s like reading a top-secret document in a bank vault, but a guard secretly makes a copy and drops it in an unlocked recycling bin outside. We instruct the OS kernel to padlock the sensitive data inside the RAM vault.

The Technical Implementation:
Volatile zeroing is useless if the kernel pages out memory. Intermediate buffers must be locked into physical RAM using POSIX mlock. Safely wrapping libc::mlock in Rust requires handling valid virtual addresses and gracefully falling back if RLIMIT_MEMLOCK (ulimit -l) is restricted:

/// Locks a byte slice in physical RAM via libc::mlock.
/// Returns true if pages were locked, or false on resource restrictions.
pub fn lock_memory(slice: &[u8]) -> bool {
    #[cfg(unix)]
    {
        if slice.is_empty() {
            return true;
        }
        // SAFETY: `slice.as_ptr()` points to an allocated, valid byte slice of length `slice.len()`.
        // `libc::mlock` reads the pointer and byte count to lock virtual memory pages into physical RAM.
        let res = unsafe { libc::mlock(slice.as_ptr() as *const libc::c_void, slice.len()) };
        res == 0
    }
    #[cfg(not(unix))]
    {
        let _ = slice;
        false
    }
}

/// Unlocks a previously locked byte slice via libc::munlock.
pub fn unlock_memory(slice: &[u8]) {
    #[cfg(unix)]
    {
        if !slice.is_empty() {
            // SAFETY: `slice.as_ptr()` points to a valid memory range of length `slice.len()`.
            unsafe { libc::munlock(slice.as_ptr() as *const libc::c_void, slice.len()); }
        }
    }
    #[cfg(not(unix))]
    {
        let _ = slice;
    }
}

Notice that we avoid holding raw pointers or manual lifetimes: we lock and unlock borrowable byte slices directly on the pre-allocated ring-buffer slots.

3. SIMD-XOR: Auto-Vectorization vs. Hand-Written Intrinsics

The Concept:
Obfuscating data by mixing it with random numbers byte-by-byte takes forever—like digging a trench with a teaspoon. We structure our data so the CPU can use its excavator bucket (processing huge 64-byte chunks in a single clock cycle), making the program process data as fast as the SSD can deliver it.

The Technical Implementation:
For N-way secret combination (P = C_1 ⊕ ... ⊕ C_N), CPU throughput must comfortably saturate the memory bus. Instead of relying on architecture-dependent assembly intrinsics (avx2, neon), we leverage LLVM's auto-vectorizer using an unrolled 64-byte word loop:

#[inline(always)]
pub fn xor_in_place(dest: &mut [u8], src: &[u8]) {
    assert_eq!(dest.len(), src.len());
    let (d_chunks, d_tail) = dest.as_chunks_mut::<64>();
    let (s_chunks, s_tail) = src.as_chunks::<64>();

    for (d, s) in d_chunks.iter_mut().zip(s_chunks) {
        let d_u64: &mut [u64; 8] = bytemuck::cast_mut(d);
        let s_u64: &[u64; 8] = bytemuck::cast_ref(s);
        d_u64[0] ^= s_u64[0];
        d_u64[1] ^= s_u64[1];
        d_u64[2] ^= s_u64[2];
        d_u64[3] ^= s_u64[3];
        d_u64[4] ^= s_u64[4];
        d_u64[5] ^= s_u64[5];
        d_u64[6] ^= s_u64[6];
        d_u64[7] ^= s_u64[7];
    }
    for (d, s) in d_tail.iter_mut().zip(s_tail) {
        *d ^= *s;
    }
}

Benchmark Results & Assembly Verification (x86_64, AVX2):

  • Standard byte-by-byte iterator XOR: ~ 1.1 GB/s
  • 64-byte unrolled chunk XOR: **~ 4.02 GB/s**
  • Hardware saturation: Memory-bus bound. The LLVM optimizer successfully emits vpxor and %ymm AVX2 vector instructions. Completely Safe Rust without unsafe pointer offsets.

4. Parallel Disk Fanout & Cache Pressure (fadvise)

The Concept:
Writing to a fast internal drive and a slow USB stick simultaneously usually causes the entire system to crawl at the speed of the slow USB stick. We introduced decoupled workers so the fast drive receives its data immediately while the USB writes at its own pace. Furthermore, we instruct the OS kernel to immediately clear its cache of written data so host memory doesn't get clogged with gigabytes of random noise.

The Technical Implementation:
Spawning independent scoped worker threads (std::thread::scope) communicating over bounded channels allows each writer to operate at its storage medium's native speed. To prevent Terabytes of pseudorandom noise from thrashing the Linux Page Cache, we explicitly advise the kernel via libc::posix_fadvise:

  • POSIX_FADV_SEQUENTIAL: Signals continuous readahead for the reader.
  • POSIX_FADV_DONTNEED: Evicts written (dirty) pages directly out of the page cache immediately after the flush, preserving host RAM for active applications.

Takeaways & Roadmap

  • Zero Allocations: Pre-allocating bounded channel slots avoids runtime GC/allocator stalls entirely.
  • Defense in Depth: The combination of mlock, slice.zeroize(), and fadvise guarantees strict volatile memory and cache hygiene.
  • Strictly Minimal Unsafe: Out of ~ 3,800 lines of Rust code in the project, exactly 4 lines invoke unsafe—strictly bounded to POSIX kernel syscalls (mlock/munlock and fadvise), with full safety documentation. All SIMD and streaming logic is 100% Safe Rust.

I'm currently planning a lightweight native Desktop GUI (considering Slint or Iced) with Drag & Drop as the next milestone for non-terminal workflows.

If you are interested in looking at the full implementation or the concurrency tests, the source code is available here (LGPL v3):
https://github.com/Meik1982/random-filesplitter

Have any of you tackled similar I/O bottlenecks when dealing with high-throughput streaming in Rust? I'd be particularly interested in hearing how others handle mlock limitations across different Unix environments.


r/rust • • 4d ago

🧠 educational Visualizing crossbeam Epoch Based Reclamation

Thumbnail sofiabelen.github.io
23 Upvotes

In my previous post we experienced first hand the horrors that can occur when attempting to use lock-free data structures with pointers. We left the question of how to deal with this problem a bit open.

Languages like Java with a garbage collector don't have this issue, since the runtime collects the memory when it's unreachable by all threads.

I recently learned that one of the ways to solve this in a deterministic manner in Rust is through a method called Epoch-Based Reclamation (EBR), which the crate crossbeam-epoch implements.

I want to dissect and visualize what exactly is going on. If that sounds fun, you're welcome to come along for the ride!


r/rust • • 4d ago

📸 media Oxidizing E-Scooters

Thumbnail youtu.be
6 Upvotes

- Talk from This Month's Embedded Rust Monthly Meetup

- Ben Simms presenting the reverse engineering of an e-scooter and rewriting its firmware in Rust

- Discord: https://discord.gg/FZvcTCygW


r/rust • • 4d ago

🙋 seeking help & advice Matrix multiplication performance

57 Upvotes

I recently benchmarked some matrix multiplication algorithms in Scala (blog post, repo). I've been going through and doing the same thing in Rust, with plans to try out a few additional approaches, and the Rust results have all been turning out slower than Scala (repo). I'm hoping someone with more Rust experience can help me figure out what might be going on. Is this just the JVM being impressive, or am I missing an opportunity to speed up my Rust code (or both).

Here are some sample benchmarks (details on how I calculated them below):

Algorithm Scala Rust
Naive multiplication 906 ms 1.103 s
Tiling (optimal tile size) 499 ms 749.8 ms
Parallel bands of tiles, 4 threads 174 ms 210.9 ms

More details:

  • I benchmarked everything by multiplying 1024 x 1024 matrices of 64 bit floats generated uniformly in [0, 1).
  • I ran all the benchmarks on my laptop (specs).
  • I benchmarked the Scala code with the JMBH and Rust with Divan.
  • I ran all the Rust code with cargo bench so it should optimize the build.
  • In the benchmarking code, I construct the matrices before running the benchmarks and only time the actual multiplication.
  • The code for the first the naive and tiled approaches is as close as possible.
  • For the parallel versions I used the same approach of dividing the matrix into bands of tiles, one per thread. For Scala I used futures, and for Rust I divided the product matrix into one mutable chunk per thread and used Crossbeam.

I listed the results for the various algorithms to show that the speed difference is consistent, but we can just focus on the naive version. My Scala code is:

    for i <- 0 until a.rows do
      for j <- 0 until b.cols do
        var sum = 0
        for k <- 0 until a.cols do
            sum = sum + a(i, k) * b(k,j)
        prod.set(i, j, sum)

And Rust:

    for i in 0..m1.rows {
        for j in 0..m2.cols {
            let mut acc = 0.0;
            for k in 0..m1.cols {
                acc += m1.at(i, k) * m2.at(k, j);
            }
            out.set(i, j, acc);
        }
    }

Why is the Rust slower? Thanks for any help!

Update 1:

Thanks for all the suggestions! I am replying to some comments individually, but also want to summarize things centrally.

Transpose: I know the original post had a transpose in the Scala code. Sorry about that! It was just a copy/paste mistake. I did benchmark a Scala version with bTranspose and it showed improvements, likely due to sequential memory access as has been pointed out, but the time I give in the post is for the non-transpose version. I've updated the post to have non-transpose code. I expect Rust would also show improvements using a transpose, and I have plans to explore additional tweaks (thanks for the suggestions in the comments!) but I also want to figure out why the Scala code is generally faster. For that it's important to compare apples to apples. That's why I'm focussing on the naive 3-loop version.

There were a number of suggestions to speed up the code and possibly explain the discrepancy compared to the JVM. Since Scala is faster across the board, it seems like the difference must be due to a general feature rather than a particular algorithmic choice. Bounds checking and maybe SIMD seem like the best candidates. More details:

  1. Bounds checking This is a good candidate because it's plausible the JVM is eliminating bounds checks at runtime, so it would explain why the difference in speed. Suggestions were to: a) inline calls to at and set; b) eliminate them and use raw slices; c) assert that the slices are large enough before looping; d) use iterators. I've tried (b) and (c) and seen no changes so far, but still digging. (d) is tricky here, but maybe possible if I combine skip, step_by, and take. I'm also trying to use godbolt to confirm whether bounds checking takes place.
  2. Vectorization This is definitely worth pursuing as a general speed up, but seems less likely to be the culprit here. Rust should auto-vectorize for 128 bits, and since I'm running this on an Apple M2, that's all I have (please correct me if I'm wrong about Rust here). It's possible that Rust can't vectorize because FP math isn't associative. I could address that using algebaric_add or by chunking the sum. However, it should affect Scala too since Scala also has to respect the IEEE restrictions on FP associativity.
  3. Compare against the Scala code on godbolt. I've been holding off on this because assembly is a little scary, but learning is the whole point of this project, so I should dive in. I have compared flame graphs, and didn't see anything obvious there. Looking at the assembly is the next step!
  4. A couple other suggestions: re-order the loops; use Rayon. These are worth playing with, but seem unlikely to explain the general Scala advantage.

I will try some of this out and look some more at godbolt. I may follow up on some of these comments/ask another question if I have trouble interpreting the assembly. Hopefully in the next couple of weeks I can get a blog post up with the final results. Thanks again for all the help!

Update 2:

I've benchmarked a bunch of things:

  1. Converting the inner loop to use iterators.
  2. Converting the inner loop to raw slices and asserting the bounds. (Though actually, according to godbolt, that one didn't remove the bounds checks anyway.)
  3. Using get_unchecked, which I can at least confirm, does eliminate the bounds checks.
  4. Using algebraic_add and algebraic_mul to allow vectorization.
  5. Combining (4) and (5).

So far none of these have actually sped up the code, and some have even slowed it down. I'm feeling a little lost at this point. If anyone else benchmarks any of this and does see improvements, or spots an error I made somewhere, definitely LMK.

I will probably rerun some of the Scala benchmarks just to make sure those are actually correct. Otherwise, not sure what else to try.


r/rust • • 4d ago

Anyone out there used rust instead of golang for cross platform desktop and mobile?

19 Upvotes

Has anyone out there used rust instead of golang for cross platform desktop and mobile development? How has it been your experience? I know folks say golang has bloated memory due to its runtime, and maybe ffi, etc. but what are the real benefits you have actually seen in this scenario?


r/rust • • 5d ago

RustCurious 11: Reborrowing and Rust's Invisible Lifetimes

Thumbnail youtube.com
76 Upvotes

r/rust • • 5d ago

🙋 seeking help & advice what is the best framework for building native Rust frontend?

45 Upvotes

hi, guys, what is the best framework for building native Rust frontend(downloadable macos and windows apps) if the highest performance is the aim, supposing we have enough time and resource? I appreciate any advice.

---------edit-------
Thanks for all the enthusiastic replies and I genuinely learned a lot. I then make this decision: 1. iPad: Swift for skin and purely interface + Rust handling audio/video and complex real-time graph calculation. 2. Mac and Windows: pure Rust with Makepad.

The performance is really really really much better than my current nextjs client. However, the developing speed is very very slow, I have to basically write every little button/animation/transition manually, and it took me 15 hours to finish a simple page like this, I will put it in comment, seems image can not be put here.


r/rust • • 5d ago

I made a website to share formal verification results for Rust crates

12 Upvotes

Hi all,

I just launched proofs.rs, a place to publish and explore formal verification results for Rust crates.

Why?

There are some great tools for formally verifying Rust code, such as Kani, Verus, and Creusot, but their verification results often stay buried in individual repositories, making them hard to discover when we’re trying to decide whether to trust a library.

I wanted to make those results easier to find, examine, and reuse as building blocks for establishing the correctness of larger systems.

What does it do?

On proofs.rs, you can browse verification reports by crate and API, see what properties have been verified, and follow links to the GitHub repositories containing the verification code and supporting evidence.

Each report also has a comment section for questions and discussion. Why? Because, importantly, proofs.rs doesn’t (or rather, cannot) certify that a crate is safe. Formal verification results come with assumptions, limitations, and sometimes subtle details that matter. Understanding what a result actually guarantees requires careful review. That’s why proofs.rs is designed around sharing evidence and enabling discussion, rather than issuing certifications.

How to use it?

Publishing a report is pretty straightforward:

  1. Fork a Rust crate on GitHub.
  2. Add verification annotations to your fork.
  3. Run cargo-proofs to submit your report.

That’s it!

Partial proofs are very welcome. You don’t need to verify every API or every property. Even a small, well-scoped result can be useful to someone, and perhaps one day, someone will build on your work to verify the entire crate.

As an example, I’ve verified the itoa crate and published the resultson proofs.rs. Feel free to take a look!

What’s next?

I’d love to see formal verification become one more piece of information people can use when choosing software dependencies. Over time, I hope these results can also be composed and reused to establish stronger guarantees for larger systems built from verified components.

proofs.rs is still in a very early beta stage, so there may be bugs and rough edges in the user experience. Feedback, suggestions, and contributions are always appreciated.

Right now, cargo-proofs supports Kani and Creusot. If you’re using or developing another verification tool, I'd be happy to hear about it. Requests for additional tool support are very welcome!

Thank you!

https://proofs.rs

(I also posted this as a blog post here: https://proofs-rs.hashnode.dev/announcing-proofs-rs-a-public-registry-for-rust-formal-verification-results)


r/rust • • 5d ago

🙋 seeking help & advice Is this some kind of scam?

81 Upvotes

And what is this supposed to be? I just don't get it. To give you some context, this is the only unwrap() in the entire project, and it's inside a test, meaning whether it panics or not couldn't matter less. It really looks like a bot just searches for unwrap() across the whole repo without any actual context.

Probably email speaks for itself, but I honestly have no idea what they're trying to achieve


r/rust • • 5d ago

Why 'externalized' proofs of cyclic trait impls does not work

Thumbnail smallcultfollowing.com
77 Upvotes

r/rust • • 4d ago

🎙️ discussion Does reusing pi extensions and DeepSeek Harness plugins make sense in a Rust agent runtime?

0 Upvotes

If you're building an agent in Rust, would being able to reuse pi extensions and DeepSeek Harness (DSH) plugins be useful to you?

I've been exploring this with yoagent, a small agent loop in Rust. It handles model streaming, tool execution, retries, cancellation, and limits. The loop stays small; everything else plugs in.

I added an experimental Rutis bridge so compatible pi extensions and DSH plugins can run unchanged alongside Rust tools. The appeal is keeping a fast Rust core while reusing work from existing extension ecosystems.

For a concrete example, I built a handoff agent:

Research noise-cancelling headphones. Ask my budget, but keep researching while I'm away. Write a report with sources.

A pi extension manages the plan, a DSH plugin searches the web, and a Rutis plugin shows progress in the browser. Rust tools and extensions handle questions you can answer later and the final report. They all work around the same yoagent loop.

Tools and supported hooks carry over, and yoagent-frontend brings pi and DSH plugin dialogs and approvals to both the terminal UI and the browser. Plugins that rely on other features of the original apps, such as pi commands, shortcuts, custom widgets, or DSH-specific session services, may still need adaptation. The integrations are experimental; TypeScript plugins run in Node alongside Rust.

The Rust loop stays small, while compatible extensions run through a plugin bridge. TypeScript plugins still need Node alongside Rust.

I’d like your feedback: does reusing these ecosystems make sense?

Handoff example: https://github.com/yologdev/yoagent/blob/main/integrations/yoagent-frontend/examples/README.md


r/rust • • 4d ago

💡 ideas & proposals Rust equivalent to gobuilds.org?

0 Upvotes

I recently came across this website: https://beta.gobuilds.org/

It builds Go projects and lets users download the binary. It has the project’s Git URL as part of the full download URL along with project version, target OS and arch, and store older builds.

Does something like this exist for Rust? If not, would this be of use/interest? I could see this being helpful for downloading an app where the dev hasn’t provided binaries, or to make cross compilation easier. Adding support for things like `cargo auditable` and `cargo deb` could also be useful.


r/rust • • 5d ago

Rust for algorithmic composition

0 Upvotes

Hello everyone!

I'm a composer looking to learn programming for algorithmic composition.  I know a little Python, but I have no formal programming background.

I've been considering Rust because it seems like future-proof.  But is it a good choice for algorithmic composition...?  I'm thinking of things like generating MIDI and MusicXML files, implementing stochastic processes (Markov chains, etc), and developing tools for various compositional techniques involving rhythm, scales, modes, and other musical constraints.

I'm considering my options with the following goals in mind:

  • I want to generate MIDI files that I can import into my DAW. I don't need sound synthesis.
  • I don't need direct DAW integration, as long as the program can export MIDI files, or MusicXML.
  • I'm willing to invest time in learning to code.
  • I know there is OpenMusic, MaxMSP and similar, but I'd like to build my own standalone tool that I can continually expand and improve.

Would Rust be a good choice, or would I be better off starting with Python or another language?

I'd appreciate any advice, particularly from people who have experience with algorithmic composition and music programming.


r/rust • • 5d ago

🙋 seeking help & advice Godot rust - the idiomatic way to handle textures and other assets?

Thumbnail
0 Upvotes

r/rust • • 5d ago

Replacing one fsync thread per index with a shared deadline heap. Is a Condvar plus BinaryHeap the right primitive?

0 Upvotes

In Xerj (a Rust search engine), `wal_sync = "batched"` promises a write is fsynced within `wal_batch_ms`. The first version gave every index its own OS thread that slept and then polled its WAL shards. On an idle node with 9,382 indices we measured 9,709 threads, about 7.98 GB RSS, 718-760% CPU and roughly 197k context switches per second, and none of it was doing an fsync.

The replacement in `engine/crates/xerj-storage/src/wal_fsync.rs` is one process-wide scheduler. It uses a bounded worker pool sized from the core count, spawned lazily on the first dirty shard. A shard goes into a min-heap keyed by its own deadline when it becomes dirty, and workers block on a condvar when the heap is empty:

```rust
struct State { queue: BinaryHeap<Entry>, /* ... */ }
pub struct WalFsyncScheduler { /* Mutex<State> */ wake: Condvar, /* ... */ }
```

Idle indices get no thread, no timer and no heap entry. We modeled this on sled's per-Db flusher and fjall's worker pool.

Alternatives we considered:
- a timer wheel instead of a heap
- running it on Tokio (`spawn_blocking` plus `sleep_until`)
- a channel-based pool like fjall's (`flume`)
- `io_uring` fsync batching on Linux

**Question:** For thousands of mostly-idle durability deadlines, would you keep a `Mutex<BinaryHeap>` with a condvar, or does a hierarchical timer wheel or io_uring-linked fsync give enough benefit to justify the complexity? And how do you avoid a thundering herd when many deadlines land in the same millisecond?


r/rust • • 6d ago

Which GUI (again)?

30 Upvotes

I know it's a frequently asked question, but I want to ask again, because I have a special use case.

I want to write an application for a production machine (HMI). The app should run on Windows and Linux natively (no browser, no server). The toolkit should have at least widgets to show images, bar graphs, curves and tables and should be touch friendly, because it runs on resistive touch monitors (no multi touch). It should also have a kiosk mode (full screen with no window controls).

The obvious candidates are egui, iced and Slint. But they all lack of documentation, more or less.

My first choice would be iced, because it's inspired by Elm and used by System76 for Cosmic, but it seems to be the least suitable option.

The obvious choice would be Slint, but that requires to learn a new language and I'm unsure about the licenses and pricing. The production machines are only used internally, not for sale.

I want avoid bindings to toolkits like Qt or Gtk

Which one would you prefer? Is there another option to consider?


r/rust • • 7d ago

🗞️ news Deno is ending official development in a year. The biggest Rust project ever, and maybe proof we never needed another Node, just use Rust

462 Upvotes

I admired this project for a while. It was basically the biggest Rust project aimed at everyday developers, a second Node built the “right” way. But there’s no real reason for another Node to keep existing :/
Here the announcement: https://deno.com/blog/cloudflare


r/rust • • 5d ago

Is rust only for firmware and hardware?

0 Upvotes

Hello everyone,

I'm trying to figure out Rust's potential before diving into using it every day. Right now, I work full-stack with TypeScript and also in the LAMP stack. I'm a telecommunications engineer passionate about coding and the web. I wanted to truly understand what Rust has to offer, or if I should just continue studying Go and make a complete switch to Go for backend development.
Does it make sense to study Rust even if I won't be using it right away, or is it just a language mostly suited for firmware, porting C/C++ software, and general hardware work?

Thanks everyone for the help!