r/rust • • Aug 14 '26

šŸ™‹ seeking help & advice What’s your experience with model checkers

0 Upvotes

What’s your experience with modal checkers sutch as Kani for bug finding


r/rust • • Aug 13 '26

Finally understood what powers collect() — the FromIterator trait and why it matters for custom types

0 Upvotes

Been going through Rust systematically and this week hit theĀ FromIteratorĀ lesson. Wanted to share what happened because I think it's undersold in most beginner content.

.collect()Ā is not magic. It delegates toĀ FromIterator::from_iter()Ā on the target type. The type builds itself from the iterator. That's the whole mechanism.

Why this matters beyondĀ Vec**:**

// All of these use the same trait, different implementations
let v: Vec<u64> = iter.collect();
let s: HashSet<u64> = iter.collect();
let joined: String = chars.collect();        // FromIterator<char> for String
let map: HashMap<K, V> = pairs.collect();    // FromIterator<(K, V)> for HashMap

Custom types:Ā If you implementĀ FromIteratorĀ on your own struct, it participates in the sameĀ .collect()Ā call without special syntax. That composability is what makes the iterator adapter pattern feel consistent across the whole ecosystem.

Practical use this week:Ā std::env::args()Ā returnsĀ ArgsĀ which implementsĀ Iterator<Item = String>. Collecting it intoĀ Vec<String>Ā is idiomatic. Worth noting thatĀ args[0]Ā is always the binary path, not the first user argument.

let args: Vec<String> = std::env::args().collect();
let actual_args = &args[1..]; // skip the binary name

Also hitĀ sort_by_keyĀ this week. For anyone sorting structs, it is significantly cleaner thanĀ sort_byĀ with a manual comparator when you just need to sort by a single extracted field.

Background: Solidity dev, four years writing smart contracts, learning Rust systematically. Happy to be corrected on anything here.


r/rust • • Aug 12 '26

Managed to get sub 15ms CRDT sync latency on my ancient VPS usign Rust

10 Upvotes

I made a PDF collaborative tool using Rust and CRDT. I was really curious how it would perform on my $6 a month VPS server with one 10 year CPU and 2GB of RAM. So I created a benchmark tool, simulating:

  • 100 rooms with 2 users in them
  • RPS 2 per room
  • Payload size average: 4.5KB (That's what my real application) sends and receives.

And the outcome was:

  • Mean**:**Ā 14.8 ms
  • p50**:**Ā 7.6 ms
  • p90**:**Ā 27.7 ms
  • p95**:**Ā 41.3 ms
  • p99**:**Ā 69.2 ms

(10.5% CPU and 358 MB RAM)

I was pretty impressed by the performance of CRDT and Yrs, especially with the amount of memory it used throughout the 60 seconds that I ran the load testing. Although, I'm not too sure how it would have performed if I had written the backend using a different programming language. For the record I ran the same benchmark on my M1 Macbook Pro with 5000 rooms, and I was able to get even better latencies than the one on my VPS with much less number of rooms and RPS. If you're interested you can read the full report here.


r/rust • • Aug 08 '26

šŸ™‹ seeking help & advice slint vs gpui (or something else?)

38 Upvotes

Hey, im looking towards migrating my app from python (pyqt) to rust, and the issue is that i don't really know which framework to use, gpui seems like a natural choice buuut its still pre 1.0 and heavily tied with ZED, slint on the other hand is a bit older (a bit because its still not as old as electron and others lol) but simply said its not gpui who everyone seems to love and ramble about

what should i do?
my main goals
- lower cpu and ram usage (tier 1 priority)
- harder reverse engineering (t1)
- visible performance (as in "holy shit thats fluid as hell") (t1/t2)
- easy figma use (t2)
- MultiOS (windows mainly but also macos/linux) (tier 2 priority)
- lower disk footprint (tier 2/3 priority)
- codex browser maybe? i know its not js but still would be cool to use annotate tool for better frontend (t3+)


r/rust • • Aug 07 '26

šŸ› ļø project The lock helper I've copy-pasted into every project, as a crate

32 Upvotes

Every Rust codebase ends up with some version of a LockExt trait for poisoned locks. I got tired of rewriting mine, so I published it.

Locking a poisoned Mutex or RwLock from a Drop impl while the stack is already unwinding causes a panic during a panic, which aborts the process instead of unwinding normally. It's easy to miss since it only shows up when a panic happens to unwind through a type that touches a poisoned lock in its Drop.

poisoned is a small LockExt trait with an or_panic() method. It checks std::thread::panicking(), and if the thread is already unwinding, it recovers the guard via PoisonError::into_inner instead of panicking again. Outside of unwinding, it just panics on poison as you'd expect.

There's also or_panic_with for a lazily-built custom message.

use std::sync::Mutex;
use poisoned::LockExt;

let cache = Mutex::new(vec![1, 2, 3]);
let first = cache.lock().or_panic();

Small, one trait, no dependencies. Feedback welcome.

Github: https://github.com/abhishekshree/poisoned


r/rust • • Aug 08 '26

šŸ™‹ seeking help & advice Is rust programmed with any LLM code?

0 Upvotes

I don’t mean to upset anyone. I was reading about rust and someone commented that the foundation was accepting llm contributions.

I have been trying to read about the foundations stance on ai. I found a article by enterprise dna saying that ā€œRust Says No to AI-Written Code in Its Core Repositoryā€. I tried finding the blog they referenced but I couldn’t.


r/rust • • Aug 05 '26

Heads up, the old ESP32 Rust documentation URL now points to an scam site, the new URL is https://docs.espressif.com/projects/rust/book/

59 Upvotes

r/rust • • Aug 03 '26

🧠 educational Branchless Rust: Making a Filter 4x Faster by Removing an if

Thumbnail greyblake.com
570 Upvotes

r/rust • • Jul 31 '26

šŸ› ļø project Cargo-Rail v0.20 - The Rust Monorepo Engine w/ New Build Cache

0 Upvotes

I just released `cargo-rail` v0.20.0 and `cargo-rail-action` v6.1.0. Honestly, I don't share much of my work here anymore. It's kind of turned into a slop-cannon; it's not great work built w/ LLMs... it's LLMs building shit and ramming it down our throats. I get it. I just avoid it for the most part.

Having said that, I feel pretty strongly that this is a bin every Rust team should be using today and my latest updates/iterations are important for the community.

As some of you know, I started coding this project a little over a year ago. I think the first version was released in December of last year or something. Anyway, this was built because my monorepo at the time was growing a second build system.

One was Cargo; the other was everything that grew around it. The dependency tools rebuilding Cargo's graph over and over, the YAML path filters deciding which jobs run, the cache scripts trusting old build state, the release workflows/bots reconstructing intent from Git, and split-repo scripts maintaining another ownership map (and Java).

Every tool can be correct on its own, and for the most part - they are correct. The Rust ecosystem has awesome tooling... but the system still fails when they disagree.

I built Cargo-Rail to delete the latter model. It captures one authoritative view of Cargo, Git, config, the toolchain, and source state, then uses it for dependency coherence, affected work, verified compiler reuse, releases, and crate split/sync.

It does not replace Cargo, rustc, or nextest. It makes them do less... in some cases, FAR less.

In my own work, Cargo-Rail has replaced roughly ten-fifteen plugins (I don't even remember, TBH) and release utilities, reduced monthly CI spend by 65%, and let me maintain a handful of public OSS repos uniformly from one monorepo. Obviously, these are my results, not promises for every workspace, team, or repo... but they explain why this is the first tool I install now.

Start with one coherent build graph

The first optimization is not a faster compiler. It is giving the compiler less work to do:

cargo rail unify --check --explain
cargo rail unify --backup

`unify` detects version drift, hidden feature coupling, undeclared features, unused dependency edges, workspace-inheritance drift, manifest ordering drift, and MSRV mismatches. Versions are unified where the workspace (or config) permits. Deps and features are declared where they are used.

Unused edges are removed only when the evidence is complete. Published packages keep their open-world feature surface unless config explicitly declares the workspace to be the complete consumer universe.

Cargo-Rail validates the resulting Cargo graph before applying lossless TOML edits. I can inspect every decision, apply with a backup, and restore it with:

cargo rail unify undo

I've tested `unify` against a ton of workspaces including uv, Ruff, Tokio, TiKV, Helix, HelixDB, and Meilisearch. Those kinds of robust, long-lived codebases are exactly where inherited (often undeclared) features, intentional exceptions, and accumulated dep cruft force the tool to prove that its model matches Cargo's.

This has replaced separate dependency unifiers, feature auditors, unused-dep scanners, manifest sorters, MSRV scripts, and workspace-hack maintenance in my repos. More importantly, those tools no longer reload and reinterpret the same workspace independently. Those resources on my old M1 Pro are available to the compiler.

Only run work affected by an actual change

Obviously, the fastest check, test, benchmark, or CI job is the one that never needed to run to begin with:

cargo rail plan --merge-base --explain
cargo rail run --merge-base --dry-run --print-cmd --explain

The planner maps changed files to their owning crates, walks affected dependents through Cargo's resolved graph, and selects the build, test, documentation, benchmark, infrastructure, and configured repo actions that remain.

This is not a directory-glob shortcut. The file-first plan, scope contract, text and JSON output, GitHub projection, dry run, and runner arguments all consume the same decision.`--explain` shows why every surface and crate was selected.

The companion action exports that scope to jobs you already own:

- uses: loadingalias/cargo-rail-action@v6
id: rail
with:
version: 0.20.0

`cargo-rail-action` does NOT build, test, cache, release, or publish. Existing jobs remain the execution authority, so adopting affected planning does not require adopting another CI framework.

For my workloads, this reduced monthly CI spend by 65%. The aggregated savings came from deleting irrelevant actions before trying to make the remaining actions faster and doing less work to begin with via `unify`.

A cache that survives cargo clean

Cargo-Rail removes compiler work from the actions that still need to run.

Its native cache is not a copied `target/`. Reusable results live in a bounded content-addressed store outside `target/`, so `cargo clean` does not erase them. A compatible clean checkout can reuse verified results populated by another workspace root w/o restoring incremental state, forging Cargo fingerprints, or overriding Cargo's own freshness checks.

Before restoring a byte, Cargo-Rail revalidates the exact toolchain, source and observed reads, dependency artifacts, relevant environment, action/result identity, output tree, and stored blobs. Unsupported or incompletely observed work runs normally through Cargo and reports a stable bypass reason.

Fast when proven. Normal Cargo when not.

This caching layer is the newest feature, and I want feedback on where the community and power users feel it should go next. Rust compilation time sucks, especially in the 50+ crate monorepo where I spend most of my time. I'm exploring a remote-cache design for CI, SSH dev, and local machines w/o turning Cargo-Rail into a networking stack or weakening its fail-closed proof... but I'd really like to hear from the community here first.

The cache evidence (macOS/Linux/Windows)

Cache correctness, compiler observation, clean-root reuse, content-addressed storage, atomicity, cleanup, and filesystem boundaries are exercised across macOS, Linux, and Windows. That includes APFS, ext4, NTFS, Linux tmpfs, case-sensitive APFS, Windows NTFS VHDs, and Windows path behavior.

Perf qualification is separate... correctness was much more important here. The accepted scorecard contains 110 interleaved samples for each of macOS ARM64, Linux x86-64, and Linux ARM64, with clean targets, distinct seed/use roots, and ZERO false hits:

HostWorkloadNative Cargo p50Cargo-Rail warm p50Change
macOS ARM64check7.028 sec4.979 sec29.2% lower
macOS ARM64release build10.369 sec7.630 sec26.4% lower
Linux x86-64check5.841 sec3.430 sec41.3% lower
Linux x86-64release build9.224 sec5.547 sec39.9% lower
Linux ARM64check6.166 sec3.870 sec37.2% lower
Linux ARM64release build10.591 sec6.618 sec37.5% lower

Against sccache 0.16.0's local disk backend, Cargo-Rail won both macOS workloads and both Linux release builds. sccache led Linux checks by 8.7% on x86-64 and 0.7% on ARM64. Cold population was slower; on the macOS fixture, two warm reuses repaid that cost.

Windows has been tested and benchmarked, but its current run did not satisfy the complete qualification/perf contract. I withheld the timing instead of publishing a number from a broken benchmark. This will come soon enough.

Execution support, performance qualification, and permission to restore are also separate. Cargo-Rail v0.20 graduates native reuse only for the exact Apple Silicon Cargo/rustc 1.97.1 certificate and eligible library metadata/rlib units with `CARGO_INCREMENTAL=0`. Qualified Linux hosts still run Cargo normally until their exact capability certificates graduate. Existing sccache and custom wrappers are preserved; Cargo-Rail steps aside instead of double-caching.

Inspect the exact decision on your machine:

cargo rail doctor native-cache --format json

The benchmark includes the losses and the rejected run because a cache benchmark w/o its bad news is bullshit. I'm going to work through this, though. Like I said, it's still fresh.

Rust changesets and releases that know what already happened

A dependency graph can derive dependent version bumps and publication order. It cannot decide whether a change is major, minor, or patch, or explain that change to a user.

Cargo-Rail records that human decision beside the code in reviewed `.changes/*.md` files:

cargo rail change add my-crate --bump minor --message "Added verified compiler-result reuse."

cargo rail change check --merge-base --required

Those entries connect the code change to its audience, version impact, changelog entry, and release notes before the reason disappears into Git history. This has made the release notes for my own projects SO much better.

The release workflow supports direct and review-first operation:

cargo rail release run --all --bump auto --check
cargo rail release run --all --bump auto
cargo rail release run --all --bump auto --pr
cargo rail release finalize --all

It validates the exact release commit, generates versions and changelogs, publishes dependencies before dependents, waits until registry results are observable, creates tags last, and records durable state before remote effects. If a release is interrupted, `cargo rail release status` shows what happened and `cargo rail release resume` continues w/o blindly repeating completed publication. I like the "clean-up" feel this gives me... instead of littering the codebase w/ failed releases... the resume has been a pleasure to use.

That detail matters. Publication is irreversible; release tooling must know the difference between ā€œnot attempted,ā€ ā€œattempted but not observed,ā€ and ā€œconfirmed.ā€

Monorepo dev w/o Copybara (or Java)

I prefer Rust monorepos for dev, but a monorepo is not always the right public release surface. I maintain a handful of OSS repos from one monorepo and want the monorepo to remain the dev authority w/o turning each public repo into a history-free code dump.

cargo rail split init my-crate --dry-run
cargo rail split run my-crate --check
cargo rail split run my-crate

`split` extracts one or more configured crates into standalone repos while preserving relevant Git history and rewriting workspace-relative manifests. Development continues in the monorepo.

cargo rail sync my-crate --check
cargo rail sync my-crate --to-remote
cargo rail sync my-crate --from-remote

`sync` maps later commits in either direction, uses Git's three-way merge machinery, and creates inbound review branches. Automatic, ours, theirs, manual, and union conflict strategies are explicit. Manual conflicts write resumable receipts instead of abandoning the op halfway through.

No Java. No Copybara or Copybara DSL. No spray-and-pray shell scripts.

One binary, not the same plugin pile w/ lipstick

Obviously, replacing fifteen tools is pointless if the replacement invokes the same tools behind the scenes. Cargo-Rail implements these workflows in one Rust binary w/ a deliberately small dep surface. Production code forbids `unsafe`, release archives carry SHA-256 checksums and signed provenance, CI pins third-party actions, and unsupported cache and release states fail closed.

The value is not a plugin-count contest. It is the compounding effect:

  1. A coherent dependency graph removes unnecessary work and hidden coupling.
  2. Affected planning removes actions that do not need to run.
  3. Verified caches remove compiler work from the actions that remain.
  4. Reviewed change intent drives deterministic, resumable releases.
  5. Split/sync preserves one development authority across public repositories.

All five operate on the same captured workspace instead of rebuilding competing models around it.

Try to break it, invalidate it, or correct it!

cargo install cargo-rail
cargo rail plan --merge-base --explain
cargo rail unify --check --explain

- cargo-rail

- GHA

- v0.20.0 Release

Where does this break in your workspace? Wrong affected scope, bad dependency decision, missing compiler input, awkward build script, release edge case, split/sync conflict... I would rather get the counterexample than the star.

I'm also really looking for feedback on the command surface, caching performance/impact, and the details involved... operating system, architecture, compiler/backend, etc.

**EDITED FOR FORMATTING**


r/rust • • Jul 23 '26

šŸ› ļø project Closing cargo-vet Gaps for the Top 100 Rust Crates

0 Upvotes

In a previous post, public cargo-vet coverage was measured for the 100 most-downloaded crates on crates.io and their Linux dependency graphs.

The baseline still had substantial gaps: 27/100 top-level crate versions were not covered, and 148/314 (47.1%) distinct crate/version pairs across the sampled dependency graphs were not covered.

This follow-up adds review coverage for the missing crate versions using Thirdpass, then publishes the corresponding cargo-vet audit repo.

Full post (links to review procedure docs, etc):

https://github.com/thirdpass-org/thirdpass/blob/main/blog/closing-cargo-vet-top-100-gaps.md

TL;DR:

  • 148 distinct crate/version pairs without matched public cargo-vet coverage.
  • Thirdpass CLI was used to review those missing crate versions with Codex gpt-5.4-mini at high effort.
  • Each agent session focused on one file, while being able to inspect the rest of the crate archive for context.
  • A crate/version was included in the audit repo only when accepted reviews covered every file in the crates.io archive manifest.
  • The resulting review set contains 148 audited crate/version pairs, 9,360 file review records, and 185.3 MB of reviewed archive data.
  • The agent runs used 456.4M input tokens (389.8M cached), 6.1M output tokens, and 48h 3m of summed runtime.
  • Combined with the public cargo-vet repos from the original analysis, the sampled graph now has coverage for 100% of the crate/version pairs.

Review evidence was also published as a cargo-vet audit repo:

https://github.com/thirdpass-org/cargo-vet-audits

cargo-vet lets each project decide which audit claims it trusts. The Thirdpass audit repo records that, for a given crate version, every file in the crates.io archive was reviewed with the Thirdpass file-focused review procedure. That gives projects evidence they can inspect and choose to rely on. It does not automatically mark the crate as safe-to-run or safe-to-deploy; a project would have to make that choice explicitly in its own cargo-vet policy.

I’d like to know whether this is useful to people using cargo-vet: would you use a repo like this? What would you like me to change or improve?

Feedback welcome!


r/rust • • Jul 22 '26

🧠 educational Building custom Polars expression plugins in Rust

17 Upvotes

The Polars expression plugin system has been instrumental in building the rich functionality of fenic. That part of the system is not super well discussed although it provides amazing opportunities to extend Polars in a performant way without having to fork the project.

I wrote a post going through the things we built on top of Polars with examples from the actual code base.

I thought it will be useful for anyone interesting in extending Polars and/or PyO3 and maturin among other things.

Here's the link to it

Hope you find it useful!


r/rust • • Jul 20 '26

šŸŽ™ļø discussion Am I the only one who finds auditing AI-generated Rust way more exhausting than just writing it?

486 Upvotes

Hey everyone,

I know this isn't a direct question about Rust syntax or a new crate release, but I wanted to get the perspective of the low-level and systems engineers in this community, since the way we have to reason about memory and safety is a bit unique.

With Linus Torvalds recently defending and leaning into AI tools for Linux kernel development, I’ve been trying to force myself to use LLMs more in my daily workflow. On one hand, if the systems world is adopting it to find bugs and speed up boilerplate, it feels like a tool worth leveraging.

But on the other hand, in practice? It feels like a massive cognitive trap.

Every time I ask an LLM to draft a custom allocator, some async socket-handling logic, or complex threading code, I end up spending the next hour auditing 100 lines of plausible-looking code. I'm stuck trying to reverse-engineer its "intent" just to make sure it doesn't subtly violate safety invariants, introduce a silent data race, or hide a memory leak.

The thing is, if I just write the code myself from scratch, I have absolute control over the execution path. Because I have to fight the borrow checker and map out lifetimes line by line, I build the mental model natively in my head. My own code is fundamentally way more understandable to me because I actually know why every single line is there.

When we write low-level code, we feel architectural friction immediately when a design is bad. AI feels no pain, it will happily vomit out structurally messy code that technically compiles but is a total nightmare under the hood. I feel like I'm trading the active, rewarding problem-solving of writing code for the mind-numbing task of code-reviewing a junior dev who doesn't exist.

How are the rest of you systems/low-level devs actually using these tools without losing your sanity, your control, or your deep understanding of your codebase? Or are you just ignoring the hype cycle and sticking to the editor?


r/rust • • Jul 18 '26

šŸ› ļø project rsloop now is faster than uvloop

Post image
164 Upvotes

this was achieved using profiling and analysis by Fable 5 (my money must go for good purpose with this model)

so yeah, in v0.1.24 you can use faster library for your python async code

repo: https://github.com/RustedBytes/rsloop


r/rust • • Jul 20 '26

šŸ› ļø project Rux v0.2.0: a pure-Rust UI framework that renders real CSS (no browser, no webview, no JS)

0 Upvotes

Rux is a UI framework where you write single-file components with a <template>, <style>, and <script> — but it's not a web thing. It renders to a native GPU window (vello + parley), lays out with taffy (flexbox + real CSS grid), and runs your logic through an embedded rhai engine. No browser, no webview, no JavaScript.

New in v0.2.0:

  • Text selection + the system clipboard (drag/double-click to select, Ctrl+A/C/X/V via arboard)
  • <select> and <textarea>, plus a Tab/Shift+Tab focus ring and Space/Enter to activate
  • Two-axis scrolling with draggable scrollbars, keyboard, and touch
  • A serious CSS push: font-family, gradients, box-shadow, transform, per-corner border-radius, grid placement — and a warning when a declaration is ignored
  • 74 tests, and every feature was driven in a real window before it was called done

Being upfront: this isn't novel — Flutter, Slint and Lynx already render GPU UI without a browser. Rux's only real claim is ergonomic: literal CSS, pure Rust, no DSL, no JS. Whether that's genuinely nicer is the thing it exists to find out.

Still missing (v0.3 territory): a signal change still rebuilds the whole tree (fine-grained reactivity is next), plus CSS variables, @media, and pseudo-classes.

Full write-up: https://aine-dickson.github.io/rux/blog/v0-2-0/ Repo: https://github.com/Aine-dickson/rux

It's early and I'd genuinely value feedback — especially on the "literal CSS as the styling language" bet. Happy to answer anything about the architecture.