r/learnrust • • 21h ago

What i need to know

Thumbnail
1 Upvotes

r/learnrust • • 23h ago

To Async or Not to Async: Building a Rust MCP Server for rust-analyzer

Thumbnail developerlife.com
3 Upvotes

r/learnrust • • 1d ago

Any reason to avoid Comma First style?

4 Upvotes

I come from a SQL and python background, and writing DDL in SQL has gotten me very accustomed to writing code with commas out front when listing and writing data structures. It makes each line a bullet point that is very easy for the eyes to scan.

Something that feels very similar to me is writing enums and match statements. Is there any reason not to use this formatting? Whenever I do, RustRover (my IDE) tells me I shouldn't and gives me annoying warning lines. I'm sure I can configure it not to, but wanted to make sure I'm not trampling over a real reason to avoid that style. Any thoughts?

ex:

enum Furniture {
Chair
, Table
, Desk
, BedFrame
, Couch
}

match Furniture {
Chair => {}
, Table => {}
, Desk=> {}
, BedFrame=> {}
, Couch=> {}

r/learnrust • • 1d ago

Wasmtime fixed a critical sandbox escape bug (CVSS 9.3)

1 Upvotes

Not sure if Rustaceans in this sub saw this news earlier this month. But given AI agents are getting very good at escaping sandboxes now, it might be worth your attention to patch Wasmtime.

TL;DR: A typo in a validation check let a malicious WebAssembly guest pass an invalid callback signature, overflow the host’s native stack by up to 16KB, and potentially run arbitrary code on the host. Fixed in Wasmtime 48.0.4 and 49.0.2.

Wasmtime is a WebAssembly runtime written in Rust, built by the Bytecode Alliance (Fastly, Mozilla and others are members). It runs WebAssembly modules and components outside the browser, often as a sandbox for untrusted code.

Wasmtime published a critical security advisory on 2 October, GHSA-32h6-97mm-8q3c, CVSS 9.3. The bug sat in the component model’s handling of async callbacks.

Three checks were missing or wrong:

  • The validator in wasmparser (crates/wasmparser/src/validator/component.rs) checked a callback’s signature with this line: if func_ty.params() != [ValType::I32; 3] && func_ty.params() != [ValType::I32] { It used && instead of ||, and it checked params() twice instead of checking results() at all. A callback only failed validation if it matched neither shape, so the result type was never checked.
  • Wasmtime recorded the callback’s index without checking its arity or return type itself, trusting the validator to have done it. The host-to-guest trampoline had no bounds check on its parameter and result buffer either.
  • The stack space reserved for the callback’s return value was sized for the expected arity, not the actual one.

A guest module can supply a callback with an invalid return type that still passes validation. Wasmtime then writes up to about 16KB of guest-controlled data onto the host’s native stack, which can overwrite a return address.

Vulnerable versions: wasmtime 39.0.0 up to 48.0.4, and 49.0.0 up to 49.0.2. Fixed in 48.0.4 and 49.0.2. A workaround is to disable component-model-async, or to validate components with wasmparser 1.260.0 or later before passing them to Wasmtime.

Link to the original source - https://github.com/bytecodealliance/wasmtime/security/advisories/GHSA-32h6-97mm-8q3c


r/learnrust • • 1d ago

Curated Guides for Intermediate Rust: Lifetimes, Reborrowing, Trait Objects, and the Typestate Pattern

11 Upvotes

1. Memory & Borrowing Mechanics

  • Understanding Rust Lifetimes

    A visual, step-by-step breakdown of reference semantics, lifetime annotations, and how the borrow checker verifies memory safety.

  • Demystifying Rust Reborrowing

    An under-the-hood look at how and why the compiler allows multiple sequential mutable borrows without conflicting.

2. Types & Architecture Patterns


r/learnrust • • 1d ago

Google published its internal Rust style guide

372 Upvotes

Google just published its Rust style guide, which it says is developed in consultation with Android, Chromium, Fuchsia and Chrome. Most of it is uncontroversial, but a few rules go against what most of the ecosystem does:

  • Flat file layout. Crates live in a single directory with no subdirectories. If you feel the need to organise a crate into folders, Google says that's a sign the crate is too big and should be split.
  • No glob imports, except for merging C++ namespaces.
  • Avoid Rc and Arc. Prefer unique ownership and borrowing. Google explicitly says engineers coming from other languages reach for shared ownership too quickly.
  • No async/.await in Chromium, and don't start threads through std.
  • Avoid panics, prefer expect over unwrap to document the invariant, and never use catch_unwind.
  • Library vs application code. API design rules are binding for libraries but only a strong recommendation for apps, where simplicity should win over reusability.
  • Don't use traits to organise code. Traits are for generics, impl Trait/dyn Trait, and extension traits.

The stated reason for the deviations is Large-Scale Changes. Google wants code that tooling can refactor across the entire codebase, which explains the flat layout and the anti-glob-import stance more than readability does.

Update

Forgot to attach the link https://google.github.io/styleguide/rustguide.html


r/learnrust • • 2d ago

The Hidden Challenges of Rust Infrastructure: Interview with Marco Ieni

Thumbnail serokell.io
19 Upvotes

Rust's infrastructure supports millions of developers, but much of it is maintained by a small team of engineers and volunteers.

We interviewed Marco Ieni from the Rust Foundation about the challenges of keeping that infrastructure running.

A few interesting points from the conversation:

  • Moving from GitHub large runners to standard runners helped cut CI costs by roughly 75%.
  • Sometimes wasting CPU is the better choice if it makes CI simpler and more reliable.
  • Infrastructure permissions make it difficult for external contributors to help, even with relatively straightforward changes.
  • Running untrusted code is still a challenge, and engineering capacity is often a bigger obstacle than finding a technical solution.
  • If Rust's ecosystem grows another 10x, CDN traffic could become one of the biggest concerns.

Marco also talks about release-plz, infrastructure as code, and why the Rust project should focus on providing solid building blocks rather than opinionated tooling.


r/learnrust • • 2d ago

Today, I've had a read through the pros and cons of Rust. One of it's listed pros was its 「logical, functional syntax」. However, the very same article also says the syntax is 「complex」 and difficult to learn. Isn't this a contradiction?

2 Upvotes

Now, I do have a slight personal bias against Rust, so please forgive me if I sound overly critical. Usually, if a system of syntax is 「complex」, it is illogical and has lots of exceptions. In contrast, if the system is 「logical」, that means it's simple, easy, and regular. So how can the two exist within the same programming language? Just sounds like pompous marketing sham to me.

EDIT: I have finally found my answer, and I sincerely apologise to all of you for wasting your time. I will delete this post on 1st November, but just in case I forget, the mods can go ahead and delete it for me.


r/learnrust • • 3d ago

WHIRLWIND •T - A Local Rust Transaction Kernel for Agentic Authority

Thumbnail
0 Upvotes

I think things will change.


r/learnrust • • 4d ago

Best Rust Blogs for Beginners?

Thumbnail
7 Upvotes

r/learnrust • • 4d ago

Learning Rust - learnrust.net?

34 Upvotes

Good evening!

Started going through the book, and saw the snippet that it’s catered to those with slightly more experience. While searching around for something more friendly to complete beginners I stumbled up the website above.

I’m enjoying it and it seems well written, even has parts that made me laugh, so it definitely has kept me engaged.

My question is has anyone else gone through this? Or heard of it? It seems like it’s fairly new and I couldn’t find a single post of someone talking about it.

So far it seems solid but then again, I’m quite ignorant to all of this and wanted some opinions.

Thank you!


r/learnrust • • 5d ago

Draxbyte: a local-first disk cleaner in Rust + egui (single ~16 MB exe, never deletes without approval)

Post image
0 Upvotes

r/learnrust • • 5d ago

Coding quality standards

14 Upvotes

I use cargo deny fmt and clippy checks on my rust projects but I've just added https://github.com/RAprogramm/cargo-quality . Wondering if there are other things I can use to scan over my code to check it's quality?


r/learnrust • • 6d ago

Kavro project

0 Upvotes

Hi, i just wanted to share my project for ImGui that also uses Rust, you can create windows with imgui just by drag & drop no code, exporting to Rust code or applying it into your project : D
https://kavro.pro


r/learnrust • • 6d ago

Built my first #![no_std] lock-free hash map in Rust to learn systems programming feedback & code review appreciated 🥀

3 Upvotes

Hey everyone I’ve been experimenting with low-level systems programming in Rust and built a tiny, #![no_std] lock-free map using atomic CAS and open addressing. First time sharing an open source systems project, I’d love to hear your thoughts or code critiques! ❤ the link https://github.com/voryiex/Titan-Cache-Engine


r/learnrust • • 7d ago

Leptos islands + htmx: dropped hydration comments, dead islands, a memory leak

Thumbnail
2 Upvotes

r/learnrust • • 7d ago

Terminal App in Windows, typing results in double output

2 Upvotes

Hi all,

I try to learn rust. I create a client-server chat in pure rust. To get some benefit for the client part I use the crate crossterm in ver 0.29.

On Linux the client work fine, on Windows, there is a strange behavior. Every time I click a char on the keyboard, two of this char printed in the terminal.

It is a full Win11 Installation, no VM.

Any suggestions to this problem?


r/learnrust • • 7d ago

leptos-islands-htmx: Leptos islands that keep working when htmx swaps the page

Thumbnail
1 Upvotes

r/learnrust • • 7d ago

Advice: for a serializable sealed mailbox envelope, is manual Drop zeroization enough if Clone + retries mutate state?

Thumbnail
1 Upvotes

r/learnrust • • 8d ago

Rust Borrow Checker Bug: 11 Years in the Compiler, Reproduced

Thumbnail youtu.be
0 Upvotes

r/learnrust • • 8d ago

Suggestion to mods

88 Upvotes

Block any post with “I built” or “I made” in the title.

Idgaf about your vibe coded Rust projects. This is a sub to ask questions and seek advice about Rust from people who truly want to understand the language.


r/learnrust • • 9d ago

OAuth 2.1 Server Option

4 Upvotes

Following the ArtCraft trend, I created an OAuth 2.1-only authorization server, it is written in Rust and opted for the ISC License. It follows the Internet-Draft published on September 3, 2026, and it is not backwards compatible... I just wanted to start with that.

I'm looking for opinions to decide how to continue at this point and any kind of feedback will be appreciated. =)

https://github.com/Syavne/d-OAuth-Server


r/learnrust • • 9d ago

Came from USA to Brazil :)

Post image
125 Upvotes

r/learnrust • • 9d ago

Quiero aprender Rust, no soy nuevo en programación, pero quisiera que me dieran consejos

Thumbnail
1 Upvotes

r/learnrust • • 9d ago

I built cleaner-cli: A fast and lightweight CLI tool written in Rust to clean up developer junk (node_modules, target, .cache, etc.)

Post image
1 Upvotes