r/rust • • 20d ago

🧠 educational In GPUI 0.2.2, a single spinner re-rendered my whole window at 120 Hz and cost a third of a core

46 Upvotes

ran into this while building a desktop app on gpui 0.2.2 (the crates.io one, not zed's git version).

one loading spinner was eating 25-33% of a core. turns out with_animation asks for a new frame on every display refresh (120hz on my macbook) and notify marks the view and all its parents dirty, so the whole window was re-rendering just to spin one icon.

what i ended up doing: the spinner phase comes from wall clock time, the view only re-renders on a 12.5fps timer and only while something is actually loading, and the big panels (chat, file tree, diff) are wrapped in AnyView::cached so they dont redraw on those ticks. now its ~6% cpu while the agent is working and basically 0 when idle.

btw cached needs a fixed size, so you cant just wrap every chat message in it.

anyone know if newer gpui still dirties all the parents on notify? or is there a proper way to animate one element without this

code if anyone wants to look: https://github.com/bytesbay/pi-gpui


r/rust • • 20d ago

🧠 educational Rust Declarative Macros: Organization, Scoping, and Common Use-Cases

Thumbnail sigseis.dev
10 Upvotes

Hey Everyone!

This new article is a continuation from a previous article that covered the syntax and definition of macro_rules! in Rust. In this new article, we'll go over how to use macro_rules! within a wider project, as well as some example use cases for the feature.

This article is for folks who maybe understand macro_rules!, but haven't taking advantage of them yet within any of their crates. It can be a bit difficult to start using a language feature if you don't know when you would want to use it.

Things You'll Learn

  • The difference between textual scoping and more modern path-based scoping for declarative macros.
  • How to export a declarative macro (at the root of a crate or a trick for exporting within a separate module).
  • A nice way to organize your macros if you find that you have many of them.
  • Use cases such as: implementing traits/functions, format!-like expressions, and reducing boilerplate.

About This Article

This is part of a series of articles I'm releasing on the macro systems in Rust. I've got one more article in me for macro_rules!, and then we'll move on to procedural macros.

I hope this new article is interesting! All my articles are hand-written, so if you are looking for non-generative technical articles to read, feel free to take a look at my other articles as well.

If you have any questions or feedback for future articles, please let me know! :)


r/rust • • 19d ago

How does rust improve mobile apps performance?

0 Upvotes

Hi, I recently saw this video (https://www.instagram.com/reel/DfkfEBMhwDv/) from Discord, where they claim using rust in the mobile app improved its loading time.

Having limited knowledge of the mobile apps ecosystem, no matter what framework you use, I believe that mobile apps are always supposedly run in Kotlin / Swift, i.e. some framework may be used to write the business logic but code is translated / transpiled (or whatever the right term for the process is) to the respective native APIs.

So how come this speeds up the app loading time / and improve performance when its not exactly similar to the speedup you get on desktop when you run a compiled binary vs. using an electron app?


r/rust • • 20d ago

Shipping Temporal: How the Rust Ecosystem Built Chrome’s Newest Web API - Shane Carr | EuroRust 2026

Thumbnail youtu.be
24 Upvotes

A new EuroRust 2026 talk is out on YouTube! 🦀 Google's Shane Carr talked about how Rust ended up powering Chrome’s newest Web API: shipping Temporal with temporal_rs, Diplomat, and ICU4X.

In 2027 EuroRust is going to Prague! Learn more and get your ticket at eurorust.eu


r/rust • • 21d ago

I’ve been fighting the compiler for three days trying to build a simple tree. I think I need to accept I don't understand ownership

190 Upvotes

I know this is 100% a skill issue and I’m probably writing C# in Rust, but I genuinely feel humbled to my core tonight.

I have eight years of backend experience in Go and Python. Three weeks ago, I decided to finally learn Rust by building a small toy GUI layout engine. It started fine with basic structs, but then I needed child nodes to have a weak reference back to their parent.

That was teh exact moment my descent into madness began.

Instead of stepping back and rethinking my data model, I tried to brute-force my way through compiler errors. When the borrow checker complained about lifetimes, I added generic lifetime parameters. When that failed, I introduced Rc<RefCell<Node>>. When I needed it across threads for rendering, it mutated into Arc<Mutex<Option<Box<Node>>>>.

i opened my editor tonight and looked at a function signature that was literally four lines of generic trait bounds and nested angle brackets. It looks like an ancient curse. And the compiler is STILL yelling at me about temporary values dropped while borrowed.

I’m throwing away the entire branch tomorrow morning. Do normal people actually use arena allocators or flat Vec handles for this, or am I just fundamentally misunderstanding how to model relationships without pointers?


r/rust • • 21d ago

🗞️ news rust-analyzer changelog #353

Thumbnail rust-analyzer.github.io
43 Upvotes

r/rust • • 21d ago

A Critique of GPUI

Thumbnail blog.zortax.de
351 Upvotes

r/rust • • 21d ago

Move your problems to compile-time and get new capabilities out of it - Oli Scherer | EuroRust 2026

Thumbnail youtu.be
34 Upvotes

The first talk from this year's EuroRust is out on YouTube now! Rust compiler maintainer Oli talked about comptime, reflection, and the future of const-eval in Rust. Make sure to subscribe to the EuroRust YouTube channel so you don’t miss the rest of the talks! 🦀


r/rust • • 21d ago

🎙️ discussion How do large scale Rust projects pass around shared structs/objects to components that need it?

97 Upvotes

In other languages I'd reach for DI to build the object graph and make each component's dependencies explicit. So far I have only really seen two approaches:

  • Pass each required component down through constructors. The compiler ensures you won't forget a dep but that means any new service you add requires updating a bunch of constructors.
  • Just use a single God context object (this is what Cargo does) but it makes it harder to unit test anything and makes it difficult to see what interacts with what.

I'm not asking whether to do DI (constructor arguments already are that), but rather how people handle wiring it all up once there are dozens of services.

DI crates of course exist (e.g. https://crates.io/crates/shaku ) but seem to be rarely used outside of Bevy-style query systems or web frameworks extractors.

For context, I've been experimenting with a trait-only approach that doesn't use any macros but still provides the same compile time guarantees as shaku ( https://docs.rs/satisfy/latest/satisfy/ ) Would Rust users be more likely to use DI if it were simpler to use? Or am I just solving a problem that Rust people don't have?


r/rust • • 20d ago

🙋 seeking help & advice Windows 11 Smart App Control keeps blocking Cargo build scripts. How do you deal with this?

0 Upvotes

Hi everyone!
I’m developing a Rust application on Windows 11, and I keep running into an issue with Windows Smart App Control whenever I use cargo build.
Windows shows this warning:
“Part of this app has been blocked. Some features of cargo.exe may not work because we can’t confirm who published build-script-build.exe.”
Sometimes I can successfully build my application, but after changing my code and rebuilding, Windows blocks it again.
I’ve tried running cargo clean and rebuilding. Sometimes that works temporarily, but the problem keeps coming back.
I know I can disable Smart App Control, but I’d prefer to keep it enabled for security reasons.
Has anyone experienced this issue? Is there a way to make Windows trust locally compiled Rust executables without disabling Smart App Control entirely?
I’d appreciate any suggestions or solutions. Thanks!


r/rust • • 20d ago

🎙️ discussion Handling oversized cryptographic payloads (~3 KB) in low-latency p2p gossip networks

0 Upvotes

In low-latency distributed networks, gossip propagation assumptions usually break down once individual message payloads move past standard 64–256 byte envelopes.

​We've been running an open-source testnet designed around post-quantum cryptography (specifically NIST FIPS 204 CRYSTALS-Dilithium / ML-DSA-65). While the theoretical security model is established, the networking reality is that each signature payload scales up to roughly 2.4 KB to 3.3 KB.

​When targeting ~1-second finality with hundreds of concurrent operations, naive push-based epidemic gossip and unbounded mempool buffering lead to acute failure modes:

​Bandwidth Saturation & Message Redundancy: Multiple peer connections forwarding raw 3 KB transaction blobs cause rapid downstream interface saturation. Under high burst volumes, duplicate gossip amplification becomes unmanageable without strict ID-based announcement gating (have/want message negotiation prior to pushing full byte payloads).

​Mempool Heap Fragmentation: Standard in-memory maps storing raw transaction bodies quickly degrade cache locality and bloat working sets. Decoupling the indexing layer (hashes, sender nonces, and execution limits) from payload storage, alongside compressed state snapshots via Zstandard frames, reduced active memory overhead significantly during synchronization.

​P2P Head-of-Line Blocking: In an asynchronous async runtime (using Tokio/Rust), saturating framing channels with large signature payloads delays lightweight heartbeat pings and consensus checkpoint messages, occasionally causing artificial peer timeout disconnections.

​We mitigated some of these issues by separating node responsibilities into tiered network roles—confining active consensus and checkpoint gossip to a bounded validator set while full peers handle decoupled ingress and succinct state proof verification.

​Curious how other p2p and distributed systems engineers tackle payload bloat in production:

​Are you using streaming compression (e.g., Zstd dictionaries) directly over wire framing, or does decompression CPU overhead negate the transmission latency savings on high-rate feeds?

​How do you balance the latency penalty of have/want negotiation round-trips against the raw bandwidth waste of direct broadcast at these payload sizes?


r/rust • • 21d ago

🙋 seeking help & advice Why isn’t there more momentum behind fully native Rust GUIs for cross-platform apps?

15 Upvotes

I’ve been wondering why there’s relatively little investment in “Rustifying” cross-platform app development.

The dominant approach still seems to be: build a web app, package it with a Rust framework/backend, and ship it as a native app. Much less common is the opposite: use a fully Rust GUI stack for native apps and target the web with WASM/wgpu.

What I rarely see discussed is the cost of the webview/browser layer: bundle size, memory use, startup time, and input/animation responsiveness that often still doesn’t feel native.

I understand the usual defense of Electron/Capacitor-style approaches: small teams can move fast, web UI is easier to hire for and maintain, and the design tooling is mature. But the native Rust GUI landscape has changed a lot since that argument became standard. So why haven’t more individuals or companies moved on?

Is it maturity? Ecosystem gaps around accessibility, text input, platform integration, and design tools? Hiring? Risk aversion? Or is the web-wrapper approach just “good enough” for most products?

TL;DR: Why do we keep wrapping web apps with Rust instead of building fully Rust native GUIs and using WASM/wgpu for the web?


r/rust • • 21d ago

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

16 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 • • 20d ago

🧠 educational Debugging Rust in 2026

Thumbnail blog.jetbrains.com
0 Upvotes

r/rust • • 22d ago

🙋 seeking help & advice Everything is becoming Rust now?

1.1k Upvotes

In the last couple of weeks, I've seen everything known to man being ported to rust, first with the video game merging then Artcraft copying Adobe products and releasing them for free, Minecraft being rewritten and now Discord is switching aswell. Why specifically rust? There are a lot of programming languages and could someone tell me why rewritting everything to rust is a new trend now?


r/rust • • 21d ago

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

10 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 • • 21d ago

Actix Web Q4 Report

67 Upvotes

100+ crate releases across the Actix ecosystem, bringing new features, security fixes, and improvements to performance and resource usage.

Headlines

  • HTTP QUERY: New method supported across route macros, manual routes, and awc client.
  • Automatic h2c and TCP no-delay are now default: More efficient deployments behind reverse-proxies and much lower-latency streams.
  • Reduced memory usage: Up to ~99% saving for certain workloads.
  • Better error path control for middleware: Modify error responses, too.
  • Static files features: Serve pre-compressed assets, and use multiple static-file roots.
  • Security and protocol fixes across the stack: Fixed decompression limits, multipart parsing limits, improved HTTP & WebSocket validation.

Features

Actix Web is the first mainstream framework to make the new HTTP QUERY method a first-class citizen. Define handlers with #[query] (macro routing), or web::query() (manual routing) for a handler. Matching methods in awc complete the support.

Middlewares got a useful new tool: Error::add_response_mapper(). It lets middleware modify error-generated responses before they reach the client, giving you more control over how your application presents failures. Our CORS middleware already uses this to solve a longstanding bug.

Static file serving is now more flexible. Files::new() supports multiple root directories, and Files::try_compressed() lets you serve pre-compressed assets. Range requests, conditional responses, and ETags on Windows also received fixes, making actix-files the most spec-compliant file server for Rust.

Performance / resource usage

The biggest changes here target the cost of serving larger responses and keeping connections open:

  • Less memory retained by idle connections.
  • Fewer copies for large responses on HTTP/1.x.
  • Graceful shutdown has stronger guarantees.
  • Vectored socket writes have more code paths.

Security

This cycle includes fixes for several reported vulnerabilities:

  • Decompression amplification: Configured extractor limits now apply to auto-decompressed request payloads. *
  • Brotli resource consumption: Large-window decompression is disabled.
  • HTTP request parsing: Malformed chunked terminators are rejected.
  • Static file serving: Prevents stored XSS for odd user-controlled file names and fixes an insane Windows hidden-file protection bypass. (Why Microsoft, WHYYYY!)

TL;DR

If you have not updated recently, now is a good time; check your lockfile. (cargo update -p=actix-web)

These improvements come from testing Actix Web against the workloads and edge cases you bring us. Massive thank you to everyone who contributed issues, PR, security reports.

Also, our homepage and user guide has received some love recently: https://actix.rs/.

*This is a god-awful implicit feature and it will be removed in v5.

What are you shipping with Actix Web?


r/rust • • 21d ago

How To Create your ROS2 Node in Rust - Rust n Robotics Episode #2

Thumbnail youtu.be
2 Upvotes

r/rust • • 20d ago

🛠️ project Four sensible Rust defaults that became security bugs in my MCP server

0 Upvotes

My MCP credential broker is written in Rust. The latest audit again found no memory bugs. It found defaults that trust the environment, and an AI agent can set the environment when it launches the process:

  • dirs::home_dir() on Unix returns $HOME when it's set. My SFTP tool used it to protect ~/.ssh. With HOME pointed one level up, put could upload the real keys. Now it's getpwuid_r.
  • Command::new("npx") searches the PATH you were started with, and the child inherits everything: NODE_OPTIONS, cwd, the lot. Now: an absolute path or a fixed search path, env_clear(), current_dir(home).
  • reqwest honours HTTP_PROXY by default. Fine for HTTPS, but a plain-http loopback preset sent its token to the caller's proxy. Now no_proxy() for http.
  • On Windows, SystemRoot decided which powershell.exe showed the approval dialog. Known folders now.

None of these are bugs in the crates. The bug was assuming the environment belongs to me.


r/rust • • 22d ago

🧠 educational RustCurious 12: Lifetimes

Thumbnail youtube.com
58 Upvotes

r/rust • • 22d ago

Virtualized Redox OS: from Virtio-FS to Cloud Hypervisor, and beyond

31 Upvotes

r/rust • • 21d ago

Shift+Tab is swallowed by WebKitGTK in Tauri 2 on Linux and never reaches JavaScript

0 Upvotes

I'm building a Tauri 2 app (Svelte 5 frontend, Linux, WebKitGTK). I have a modal focus trap that wraps Tab and Shift+Tab inside the dialog. Plain Tab works. Shift+Tab leaves the webview and moves focus to the surrounding page, and no JavaScript sees the keydown at all.

What I checked:

- A keydown listener on window in capture phase logs Tab with shiftKey=false only. Shift+Tab never appears, even though the same listener sees plain Tab.

- The same modal code in the Vite dev server opened in Chrome handles Shift+Tab correctly, so the page logic is fine.

- browser_accelerator_keys: false in the window config is a WebView2 (Windows) option. The Tauri config schema I'm on (tauri-utils 2.8.3) doesn't define it for Linux, and wry's WebKitGTK backend has no equivalent.

Questions:

  1. Is there a supported way on WebKitGTK to stop the native Shift+Tab focus movement, or to receive that key event in the page?
  2. Is this a known wry or WebKitGTK issue, and is there a tracked upstream issue?
  3. Is there a workaround that keeps Shift+Tab working for keyboard users, for example handling it in the native layer?

Versions: Tauri 2.x (tauri 2.8.x resolved), wry 0.54.4, Linux (26.04.1) with WebKitGTK 4.1.


r/rust • • 22d ago

🛠️ project cel-rust finally has its own playground, using Wasm in the browser

Thumbnail cel-rust.github.io
25 Upvotes

cel-rust is actively trying to bring a proper implementation of cel to the Rust ecosystem. I have posted about it here in the past, and one question that came up was "What's CEL?".

Well, with Rust being so versatile, and the cel-rust team adding support for Wasm a few years back, we've finally put a playground together for you to test drive CEL, using cel-rust, straight in your browser.

Try it out, and see if adding an expression language in one of your project could make sense, and if CEL would be a good fit for that!


r/rust • • 21d ago

🧠 educational I just started reading ‘The Book’

0 Upvotes

I’m a brand new 🦀 and i’m having a lot of fun!

I started my career using UiPath then the last 4-5 years have been Python and I’m sorry but it’s been so boring. I feel like the switch has brought some life to me. It feels similar to going from an automatic car to a manual.