r_rust🦀
59 subscribers
593 photos
65 videos
36.4K links
Posts top submissions from the rust subreddit every hour.

Powered by: @reddit2telegram
Chat: @r_channels
Download Telegram
rbp
mov rbp, rsp
and rsp, -64
sub rsp, 192
vxorps xmm0, xmm0, xmm0
vmovaps ymmword ptr [rsp + 32], ymm0
vmovaps ymmword ptr [rsp], ymm0
mov rax, rsp
vmovaps ymm0, ymmword ptr [rip + .LCPI0_0]
vpermps zmm0, zmm0, zmmword ptr [rsp]
vmovaps ymmword ptr [rsp + 64], ymm0
vmovups xmm0, xmmword ptr [rsp + 40]
vmovsd xmm1, qword ptr [rsp + 56]
vmovaps ymm2, ymmword ptr [rip + .LCPI0_1]
vpermi2ps ymm2, ymm0, ymmword ptr [rsp + 8]
vmovaps ymm0, ymmword ptr [rip + .LCPI0_2]
vpermi2ps ymm0, ymm2, ymm1
vmovaps ymmword ptr [rsp + 96], ymm0
lea rax, [rsp + 64]
mov rsp, rbp
pop rbp
vzeroupper
ret
```

Looks about the same as my implementation, but more importantly, I observed the same performance regression.

For some reason LLVM literally generates SLOWER code if you target x86-64-v4 than if you target x86-64-v3. For context my cpu is a ryzen 7 9800x3d and I used the crate "criterion" for benchmarking.

Can someone more qualified try to explain everything to me? Why is `_mm512_permutexvar_ps` SO SLOW? Is it only a Zen 5 thing? I assume its an architecture thing considering that LLVM also generated basically the same code as me?

https://redd.it/1ryavdu
@r_rust
Hey Rustaceans! Got a question? Ask here (11/2026)!

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 official Rust Programming Language Discord: https://discord.gg/rust-lang

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.

https://redd.it/1rv3l49
@r_rust
I built a minimal process monitor in Rust with a real-time web UI (stdout / stderr)
https://redd.it/1ryp59z
@r_rust
Why is Rust so Liberal with Heap Allocations?

Ever since learning about data oriented design and the potential cost associated with system calls and trying to apply it more to my own code I've noticed that in "idiomatic Rust" it's quite common to model data as nested trees of enums with Box, Vec & String. While this is a super intuitive way to model data it's not always the most efficient.

For a language that prides itself for performance I rarely see libraries leverage alternative allocators such as arenas or other advanced data packing strategies when I peak under the hood of libraries.

Is this just a situation of focusing on readability & correctness first and avoiding premature optimization or is there something deeper going on here? Curious what your guys' perspective is.

https://redd.it/1ryxxcg
@r_rust
Rust + HTML templates + vanilla JS for SPA-like apps — anyone doing this in production?

I’ve been pretty obsessed with performance for a while, especially when it comes to web apps.
On the frontend, I’ve been using Qwik for the past 3 years instead of React and similar frameworks. I’ve even used it in production for a client project, and the performance has been great.
Lately, I started questioning the efficiency of server-side rendering with JavaScript runtimes. From some experiments I ran, rendering HTML using templates in Rust (e.g. with Askama + Axum) can be dramatically faster (I’ve seen ~30–40x improvements) compared to SSR with modern JS frameworks.
So recently I picked up Rust and started building with Axum, and now I want to push this idea further.
I’m planning a side project (a Reddit-like social media app) with this approach:
- Backend in Rust (Axum)
- Server-rendered HTML using templates (Askama or similar)
- SPA-like UX on the frontend
- Minimal JavaScript — ideally vanilla JS with no libraries unless absolutely necessary
- Very small JS bundles for faster load times
My main questions are actually about the frontend side:
- Are any of you building apps like this (Rust backend + mostly vanilla JS frontend)?
- How do you structure the frontend as it grows without a framework?
- Do you end up building your own abstractions or lightweight framework?
- How do you handle things like state, navigation, and partial updates?
Also, from the Rust side:
- Any recommendations for this kind of architecture?
- Libraries/tools that fit well with a “HTML-over-the-wire + minimal JS” approach?
I’m trying to push performance as far as reasonably possible without making the project unmaintainable, so I’m interested in real-world tradeoffs, not just theory.

https://redd.it/1rz3u23
@r_rust
einstellung - A configuration parsing and composing library

Introducing einstellung a proc-macro based, flexible, strongly-typed configuration parser for Rust.

I built einstellung because I wanted a more ergonomic way to handle configuration in Rust applications, especially when dealing with multiple layers (defaults, files, user overrides) without losing type safety or control over how things are merged.

The goal is to keep configuration definitions simple while still allowing customized advanced behavior when needed.

einstellung works by generating an associated `Partial` configuration
for your config in which every field is optional. These partial configs can then be arbitrarily loaded and merged until they are `.build()` at which point your fully initialized config struct is produced.

\- https://github.com/soruh/einstellung

\- https://crates.io/crates/einstellung

\- https://docs.rs/einstellung/latest/einstellung/

I’d be interested to hear how this compares to other config approaches people are using, or if there are gaps I should address.

https://redd.it/1rz7lur
@r_rust
Idiomatic Use of the Default Trait?

I've started working at a company where use of the Default trait is ubiquitous, as I understand to perhaps be standard in Rust. However, I somehow always wince at this when forced to read the code. If I see something as simple as
let x = false;

I've immediately learned a lot about x: I know both its type, bool, and its value, false. In contrast, when I see
let x = Default::default();

I learn none of that. I know that it must be of some type which can be inferred by its later use, and its value must be whatever that type's default is. Within some complicated logic, this can make code harder for me to read and understand sequentially.

I went looking for something I could cite to coworkers to say "this is well-established bad practice" and came up empty, which surprised me. I think of Rustaceans as having strong opinions on what code is proper. So for lack of a better source I've written my own maximalist diatribe version of this here, but I'm curious about whether if I'm truly so isolated in this belief, perhaps I could just be misguided.

Does the community in general think of Default as something to be encouraged or discouraged? In what scenarios is it seen as idiomatic, and how do you avoid this sort of confusion?

https://redd.it/1rz8pc6
@r_rust
Have tests running on file save

Hi rustaceans,

I am working in a little pet project, and I am running my tests manually, every time...

When I am working with Javascript, per example, I have at things like `jest - - watch` that runs the tests when the files are saved, and I can input some patterns (regex) to run only specific tests.

Is there an equivalent in our environment?

(I don't mind if is a cli, a vs code plug-in, or a set bash commands)

I appreciate any advice,

thank you

https://redd.it/1rz9u34
@r_rust
Announcing serde_cursor: Extract nested fields from JSON without making intermediate structs or loading the entire JSON into memory, with 5X less boilerplate than serde_query !
https://github.com/nik-rev/serde-cursor

https://redd.it/1rzajfp
@r_rust
Mods Need Input: Dealing with AI Spam in This Sub

Hey everyone, your mod team here wanting to get some feedback on something that's been bugging us for a while now


We've all noticed the uptick in AI-generated posts flooding the sub and yeah, it's getting pretty annoying. Our team is split on how to handle this mess - some of us think AI might have its place while others want to nuke it from orbit


We've been going back and forth on this for like 6 months now and can't seem to land on a solid approach that works for everyone


Look, we want to keep this place focused on actual Rust discussion and learning, but we also don't want to accidentally ban someone's legitimate question just because it might look AI-generated. Plus we're all doing this in our spare time and don't have bandwidth to review every single post manually


Right now we're just winging it case by case. You probably don't see most of our work since we've been quietly nuking the obvious spam posts, but trust me we're dealing with way more of this stuff than you realize


Here's the thing though - we're not sitting here refreshing /new all day long. We browse this sub just like you do, we all have day jobs and other stuff going on. Nobody's paying us to babysit Reddit 24/7


So what do you think? How should we tackle this without making life harder for genuine newcomers or burning ourselves out in the process


Drop your thoughts below or hit us up in modmail if you want to chat about it privately

https://redd.it/1rzkonk
@r_rust
I have a confusion about slicing with String

Hello! I am learning Rust from a Packt course and from what I learned, &str is a variable stored in the byte code of the program after compiling while String is a variable which is stored in the heap when the program runs. I was doing an exercise where I had to run following command:

let cookie_crisp: &String = &cereals[0];

let cookie: &str = &cookie_crisp[..6];

Now cereals is an array of variables of String type and cookie_crisp is a reference to the String type value stored at index 0. So, when I slice it into cookie, why is it &str instead of String. And how is this possible since &str is stored in byte code after compiling. If this data is entered by user at runtime, how is Rust handling this? I am confused. Can someone please help me understand this concept?

https://redd.it/1rzktn9
@r_rust