r/rust • • 13h ago

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

4 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 • • 13h ago

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

11 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 • • 2h ago

πŸ—žοΈ news systemd adds support for programs written in Rust

Thumbnail github.com
97 Upvotes

r/rust • • 3h ago

πŸ› οΈ project Catsor: a procedurally animated desktop cat in Rust, with no GUI toolkit (tiny-skia + x11rb / windows-sys)

Post image
84 Upvotes

Catsor is a small cat that lives on your desktop and follows your mouse. Wiggle the cursor like a laser pointer and it stalks and pounces. Shake the mouse and it gallops over. Leave it alone and it loafs, then falls asleep. It runs on Linux/X11 and Windows as a single binary.

Repo: https://github.com/ozanenginoglu/catsor (Apache-2.0)

Some details that might interest people here:

  • No sprites. The cat is a 12-node world-space chain (head, spine, tail) plus 4 planted paws. Every frame it solves the spine and tail, then tiny-skia builds the body around the skeleton with paths. Paws follow real 4-beat walk, trot and rotary-gallop phase schedules.
  • Carrier vs. displayed spine. The body follows a smooth "carrier" path. Gait wobble, head bob and butt-wiggle are added on top as offsets that never feed back into it. Before I split them, the cat slowly drifted off course and twisted its spine.
  • Oscillators are kept as running phases, not time * freq. After a few hours of uptime, f32 precision makes time * freq stutter, and changing the frequency makes the phase jump. There are tests that simulate long uptimes to catch this.
  • Deterministic simulation. CatSim never touches the OS and has its own seeded RNG. The tests are behavioral: they feed synthetic cursor paths at a fixed dt and assert on activity, positions and smoothness. The README's demo GIF is rendered the same way, from a scripted cursor driving the sim.
  • Small dependency tree: tiny-skia, glam, clap, plus x11rb (pure Rust, so no -dev packages) or windows-sys. The tray menu is drawn by hand with a built-in 5x7 bitmap font. The Linux release is a static musl binary.
  • Click-through overlays. On X11 it's an override-redirect ARGB window with an empty XFixes input region. On Windows it's a layered window via UpdateLayeredWindow.
  • Type-checking Win32 from Linux. Win32 code is gated with cfg(any(target_os = "windows", windows_check)), so RUSTFLAGS="--cfg windows_check" cargo check type-checks the Windows backend without a Windows toolchain.

Limitations: there's no native Wayland support yet, and X11 needs a compositor for transparency.

I'd love feedback on the code, especially the simulation and rendering split. Happy to answer questions about the animation.


r/rust • • 5h ago

Is Rust a good choice for game development?

59 Upvotes

I've read that in C++ you have many ways of shooting your own foot or something but there aren't any good game engines designed for Rust. I've heard of Bevy but I've heard that it's better to stick with Unity or Unreal as Bevy needs time to be at a good enough level. So the question boils down to should I learn Rust or C++?


r/rust • • 21m ago

πŸ—žοΈ news 10.0 critical CVE (RCE): update zip crate to 9.0.5

β€’ Upvotes

r/rust • • 13h ago

πŸ“‘ official blog How to fund Rust contributors

Thumbnail blog.rust-lang.org
120 Upvotes

r/rust • • 10h ago

πŸ› οΈ project Ochre: a deterministic voxel world with 32km render distances built in Rust and Bevy

Thumbnail youtube.com
44 Upvotes

Ochre is a Rust voxel project I've been working on since 2021.

Open source on GitHub: https://github.com/rornic/ochre

It started as a simple Minecraft clone using Amethyst's ECS library and plain OpenGL bindings through glium, but I migrated it to Bevy a while back to make the most of the ecosystem.

Some cool features:

  • Terrain streams in around the player and falls back to coarser LOD meshes with a cross-fade, so the curved horizon reaches 16km at the default render distance, increasing to 32km with altitude.
  • 64 km x 64 km deterministic world. Droplet erosion carves valleys, hydrology routes rivers to lakes and the sea, and a climate pass sets temperature and moisture.
  • A day and night cycle with sun, moon and stars, atmospheric scattering, volumetric clouds and weather including rain.

Built and tested on an aging RTX 2060 which currently begs for mercy at 1440p on 32km render distances. Ryzen 7 9800X3D crunches through chunk generation and meshing in an instant. Would love to see how this melts more modern GPUs!

I've found using a pure Rust engine like Bevy to be a great accelerator for AI coding harnesses too, really easy to do performance A/B tests on new engine features.


r/rust • • 16m ago

πŸ“Έ media Safe pattern for mutable + immutable access to the same HashMap in a tick loop?

Post image
β€’ Upvotes

I have a `HashMap<Coord, Box<dyn BlockEntity>>`. During a tick I need to iterate over entities and, for each one, get a mutable reference to it while also getting immutable references to other entities in the same map.

Performance is critical here, so I want to avoid Mutex, RwLock, RefCell. Right now I use UnsafeCell. I'm rebuilding something like Minecraft's block-entity tick loop (you've probably heard of it).

I've also considered a smarter iterator that marks an entry as "taken" and returns `Option` on conflicting access β€” something like `(&mut elem, &mut NonGrowingHashMap)` from `HashMap::smart_values_mut()` β€” but I'm not sure whether such a pattern exists in the ecosystem or whether it's worth building. Are there other known patterns or approaches in Rust for dealing with this kind of access?


r/rust • • 16h ago

πŸ—žοΈ news rust-analyzer changelog #351

Thumbnail rust-analyzer.github.io
38 Upvotes

r/rust • • 22h ago

πŸ› οΈ project Follow-up: rust-analyzer now runs on-device on an iPad, and it drives the syntax colors (only when there's enough memory)

Post image
39 Upvotes

Two months ago I posted here about running rustc, cargo and lld as WebAssembly on an iPad. I said I had no rust-analyzer: I had compiled it to wasm and measured it, and the proc-macro and std source costs looked too high for a tablet. It's in the app now, with a catch: it only runs when the device has the memory for it. The editor is also native now; it was Monaco in a web view then.

The screenshot is the editor with the debugger paused at a breakpoint.

What I use rust-analyzer for first is color.

Before rust-analyzer is warm, the editor is colored by a tree-sitter highlighter, and the status line says "basic colours". When rust-analyzer finishes indexing, its semantic tokens replace those colors. Both servers are translated into one vocabulary, so a word whose category doesn't change keeps its color. What rust-analyzer adds is the distinctions a grammar can't make: a trait versus a struct versus an enum versus a type alias, a method versus a free function, a macro_rules macro versus a proc-macro, value parameters, lifetimes, Self, the mutable modifier, items from a dependency crate, and unresolved references.

The memory rule, since that's the interesting part. The default is "Auto":

- device with 6 GB or more: full rust-analyzer when there is headroom, otherwise a reduced mode

- device with 4 to 6 GB: the reduced mode when there is headroom, otherwise off

- device with under 4 GB: off

"Headroom" means no memory-pressure warning and more than 2000 MB available. Pressure steps the level down one notch, and a warning expires after 45 seconds of quiet. During a build, if available memory drops below 2000 MB, rust-analyzer is released so rustc has the memory, and in Auto it comes back when the build ends (it retries every 5 seconds for about two minutes). If rust-analyzer fails to start, it is retried after 5, 20 and 60 seconds. You can also force it on, off, or to the reduced mode in settings.

The reduced mode drops the Cargo dependency graph, the crate index and code lens, the chaining, closure and borrow hints (type and parameter hints stay), and files over 200 KB. The cost is real: without the graph, crates show up as "missing reference". The graph itself needs a device with at least 7000 MB and at least 3000 MB available, and the editor doesn't attempt one for projects over 120 crates. Proc-macros only expand when a compiled reactor for that crate is already cached, otherwise the crate stays unexpanded for that graph load.

Numbers, with a caveat: I don't have an on-device warm-up time I trust yet. These are from running the same wasm under Node on a Mac:

- warm-up in a single-file project: 1.3 to 2.7 s, heap about 220 MB

- a small project with a couple of crates: about 300 MB, 1.9 to 2.2 s

- a project with 93 crates: about 500 MB, 3.4 s (about 3 MB per crate)

- semantic tokens for a 3,100-line file: 128 to 213 ms cold, 36 to 53 ms warm

- the rust-analyzer wasm is about 16 MB, built from the 2026-08-31 tag with Rust 1.98.0 for wasm32-wasip1, optimized with wasm-opt -O3

I also added GitHub Copilot after people asked for it in that thread. It uses your own subscription.

Same disclosure as before: it's a paid, closed-source app with a free tier for single files, I'm the author, and it's in TestFlight beta: https://testflight.apple.com/join/4Yaujqd5

I'd like to know where it falls over: crates that fail to build, rust-analyzer colors or diagnostics that differ from a desktop, and any device where the memory rule picks the wrong level. I'll be traveling for most of November, so replies may be slow.


r/rust • • 20h ago

🧠 educational Anyone done any work on rustc, or know how one can start contributing?

21 Upvotes

r/rust • • 14h ago

Repos/tools for fully offline Rust builds & deployments? (Like Iran internet shutdown)

6 Upvotes

Hey everyone, are there any GitHub repos or templates that help set up an offline-first Rust environment? I need to cache all toolchains and vendor dependencies while online so that building and deploying works completely air-gapped, like during a prolonged wartime internet blackout in Iran.


r/rust • • 17h ago

πŸ™‹ seeking help & advice What one "loses" when choosing to develop a web-app in rust instead of js?

8 Upvotes

If you have a personal example of a situation where you wanted to go with rust but went back to js I would appreciate that too.


r/rust • • 1d ago

Dimforge Q3 2026 technical report: Nexus multiphysics, Rapier soft-bodies, performances, and C + python bindings

Thumbnail dimforge.com
44 Upvotes

r/rust • • 1d ago

This Month in Redox OS - September 2026

37 Upvotes

More boot fixes, external display hot-plugging, page fault handling and more JIT support, big performance improvements, rlimit support, uutils 0.11, web fixes, better SDL2 performance, Clang port, i586 dynamic linking, better terminal and debugging, and many more.

https://www.redox-os.org/news/this-month-260930/


r/rust • • 14h ago

πŸ› οΈ project What obfstr/litcrypt look like after compilation, and getting their strings back from stripped binaries

0 Upvotes

Notes, code and benchmark: https://github.com/VAHPEM/rust-deobf

I've been studying how Rust string-obfuscation crates behave once compiled, mostly in the context of malware analysis, and wanted to share a few observations.

- In the tested obfstr and litcrypt cases, the original string literals don't appear as plaintext in the binary, but the decoding logic remains executable. Emulating the relevant routines is enough to recover the strings, even with opt-level = "z", fat LTO, and panic = "abort".

- In my tested binaries, panic::Location information remained available after stripping. When source paths are preserved, paths such as .cargo/registry/src/.../<crate>-<version>/... can reveal exact third-party crate versions. Compiler-related source paths may also provide clues about the Rust toolchain.

- A small litcrypt quirk: lc!(r"...") keeps a leading `"` in the decrypted value, so the program really builds `"C:\...`.

If you maintain a Rust string-obfuscation crate, or have tested one that behaves differently, I'd be interested in comparing results.


r/rust • • 1d ago

πŸŽ™οΈ discussion I want more mobile apps to be developed in Rust

76 Upvotes

Maybe you are just like me a few months ago: not sure about the feasibility of developing apps in Rust.

Now I can tell you: Rust is the perfect programming language for any apps with some actual complexity.

I am not talking about simple TODO apps. I am talking about apps that consume a lot of computation power and memory.

So far I have developed 2 apps with React Native + Rust. React Native is for UI/UX and platform-specific code, while Rust powers the core logic and state. Both iOS and Android are ARM and we know how good the Rust cross-compilation toolchain is.

The motivation for building both is for my daily use. Both are not toy projects. One of them(a Herdr/SSH client) got 200+ installations on Google Play.

It feels so nice to hold your Rust code in hand, knowing that it is using your phone's battery and memory efficiently. I started without Rust and then gradually mitigated Typescript into the Rust code. Profiling with Perfetto shows a significant decrease in latency and memory usage. The app that used to heat up my phone now feels like a breeze.

The major overhead of the mix of React Native + Rust is FFI crossing. However, if the Rust core contains almost all the states, we can minimize the data movement cost.

Therefore, for the sake of battery, memory and memory safety, please use Rust to build your mobile apps!


r/rust • • 1d ago

πŸ› οΈ project Rust rules for the Please build system

Thumbnail github.com
24 Upvotes

A year or two ago I posted the first version of this.

I reckon its ready for prod now 🀞🏼


r/rust • • 1d ago

I face a problem with opensource projects

19 Upvotes

Hello guys, As a developer who is still learning and has never contributed to projects before, I started looking for some open-source projects because I want to learn to work with a team, not just build projects on my own.

However, I've found that most projects now rely on artificial intelligence in a way that leaves little room for initial contributions. I'm not against artificial intelligence, but it's difficult for me to find projects where I can make my first contributions. What's the solution?


r/rust • • 5h ago

Help me finding rust framework

0 Upvotes

r/rust • • 1d ago

πŸ™‹ seeking help & advice Trying to find the cause of a segfault in egui

11 Upvotes

EDIT 2: Turns out the issue was specifically down to wgpu trying to use Dx12 which won't work for some reason. For anyone else having a similar issue, try following u/zettui 's suggestion of setting the WGPU_BACKEND environment variable to vulkan

EDIT: after some digging, it looks like wgpu might not be compatible with my machine, which might be the source of my problems, as it can run in some cases but not consistently.

I've been learning rust of a couple of months now, and have mainly done basic command-line toy programs, and wanted to try making a gui app with EGUI since it has support for a natively running GUI. I'm using the template that egui's lead developer provided (\https://github.com/emilk/eframe_template/tree/main) and can compile the included example, but attempting to run it causes a segmentation fault (this is using a up to date w11 machine)

So far I've tried: - Completely reinstalling the rust toolchain - Increasing the stack size to 8mb via RUST_MIN_STACK (windows default is apparently 1mb?) - Attempting to build other egui applications from source that are known to work, which gets the same error

I'm kind of at a loss for what to do, as I've tried using iced as well with similar issues, so as far as I can tell it's something that I've done, and not an issue with the libraries. If anyone else has had to solve issues like this, I'd really appreciate some advice


r/rust • • 4h ago

πŸ› οΈ project Kanzo, a tiny self-hosted kanban board you and your coding agents can share (~5k lines, one 4 MB binary)

Post image
0 Upvotes

Apparently in 2026 everyone has to build their own task board, usually with Docker, three services and half a GB of RAM to show a todo list. I built the opposite: a kanban board in your browser plus an MCP server, in one small Rust binary. Tell Claude Code or Codex "take the next task from kanzo" and it moves the card and comments as it works, which is more than I do.

https://github.com/emanuele-em/kanzo

I liked Vikunja but wanted zero setup. The one rule was keeping it small, which these days feels almost rebellious:

  • ~5k lines total. You can read the whole thing in an afternoon
  • 4.3 MB binary with SQLite inside, ~4 MB RAM idle
  • starts in 3 ms, a 3,000-task board loads in 17 ms
  • light on your agents too: ~800 tokens of tools, short replies
  • no account, no cloud, no Docker. Syncs between machines through your own private git repo if you want
  • one-line install on macOS/Linux, runs fine on a Raspberry Pi

Still early. If you've got ideas on how to make it even smaller, PRs very welcome, deleting code counts as a feature here.


r/rust • • 8h ago

πŸ› οΈ project Composure: build Discord messages in Rust with JSX-style markup

0 Upvotes

I've been building Composure, a Rust framework for HTTP-only Discord bots. This originally was a macro-driven way to group commands and route requests automatically, but grew into what it is now when Components V2 released.

I never liked the patterns for handling interactions within components, I wanted to build something that felt more like building a typical JSX app.

This is what I came up with:

use composure::{app, command, rsx, view, command::View};

/// A card that counts its likes. The count lives in the button's custom_id.
#[view]
pub fn Card(title: String, likes: u32) -> View {
    rsx! {
        <Container>
            "## " {title.as_str()}
            <Text>"-# " {likes} " likes"</Text>
            <Row>
                <Button primary on:click:like=move |_| Card { likes: likes + 1, title }>
                    "Like"
                </Button>
                <Button url="https://discord.com/developers/docs">"Docs"</Button>
            </Row>
        </Container>
    }
}

/// Post a card
#[command]
fn card(#[option("Title")] title: String) -> Card {
    Card { title, likes: 0 }
}

#[app(handlers(card, Card))]
pub struct Bot;

The click handler is written inline next to its button. Clicking Like re-renders the message with new props. The props the handler captures (likes, title) are encoded into the button's custom_id, so the counter needs no database.

Each tag expands to a builder, and each attribute to a method on it. As a result, rustc catches a misspelled attribute or a button placed where Discord doesn't allow one, and rust-analyzer completes and documents tags and attributes as you type. Limits like 5 buttons per row are checked as well.

Modals work the same way. Each input's name matches a parameter of the submit closure, so submitted values arrive typed:

#[derive(Choice, Debug)]
pub enum Severity { Low, High }

#[view]
pub fn Report(page: String) -> ModalView {
    rsx! {
        <Modal title="Report a problem" on:submit:send={move |_ctx, what: String, severity: Severity, notify: bool| {
            Ephemeral(format!("{page}: {what} ({severity:?}, notify: {notify})"))
        }}>
            <Label text="What happened?">
                <TextInput name="what" paragraph max_len=500/>
            </Label>
            <Label text="Severity">
                <RadioGroup name="severity" options=Severity/>
            </Label>
            <Label text="Notify me">
                <Checkbox name="notify"/>
            </Label>
        </Modal>
    }
}

An input without a matching parameter, a parameter without an input, or a type the input can't produce is a compile error.

Underneath, Composure handles Interactions only, which Discord sends as signed HTTP requests. A bot needs no WebSocket and no process running 24/7: it runs on Cloudflare Workers, where you pay per request, or on any server with tokio. Other features:

  • Commands are functions. Parameters become Discord options and the doc comment becomes the description, so the registered definition and the handler can't drift apart.
  • ctx.defer(async |ctx| ..)Β for work that takes longer than Discord's 3 seconds.
  • A REST client for Discord's endpoints, checked in CI against Discord's OpenAPI spec.
  • A command sync CLI. ItsΒ --checkΒ mode fails CI when the commands registered on Discord are out of date.
  • Each interaction takes a few microseconds, and the full example bot is about 307 KB of gzipped WASM.

If your bot needs to read every message or track presence, use serenity or twilight, because you need the gateway for that.

It's pre-1.0 (currently 0.2), so the API may still change. I'd really like feedback on the rsx! syntax and on what's missing.

I have ported this over to TypeScript as well, as the JSX patterns fit well, but it lacks the compiler-safety. https://github.com/BlueFrog130/composure-js


r/rust • • 1d ago

Access the value of a unit Enum

10 Upvotes

Let's say I have an enum like

rust pub enum NodeType { None = 0, Root = 1, // ... more enum variants omitted for brevity ... Leaf = 15, }

This is a special type of enum, called unit-only enum. Is there a way to access the value stored in the enum?