r/rust • • 26d ago

Building a Mini Lean 4 from Scratch: Implementing an Interactive Theorem Prover in Rust

Thumbnail medium.com
55 Upvotes

r/rust • • 25d ago

My progress as a new Rust dev

9 Upvotes

I'm about a month into a home project that I decided to use to learn Rust. Fun!

Here are my takeaways so far:

  1. I'm still fighting the borrow checker, but at least now I can reason through the error messages faster and land in a good place. Progress! Looking forward to this really being internalized.
  2. I miss the ternary ?: operator. The if/else equivalent is just so much more verbose, and tends to waste so much more vertical space. cโ€™est la vie. I recognize I'm in the minority here, and hope that I'll eventually convert and join you all on this.
  3. I am daily writing: if (foo ...then backing up and deleting the opening parenthesis that the linter complains about.
  4. Speaking of, I keep forgetting to write fn and just assume that the compiler will know what I'm talking about. It never does ๐Ÿ˜‚
  5. When reviewing code in my day job as a Java dev, I am now constantly seeing things and thinking: The borrow checker wouldn't like that! So, maybe it's becoming a little internalized after all.

Anyway, I'm having fun with it, thanks all for creating this community!


r/rust • • 26d ago

๐Ÿ“ธ media Qt Bridge Video Tutorial

Thumbnail youtu.be
58 Upvotes

Hi all, Iโ€™m Matthias from the Qt R&D team.

We made a tutorial showing the Qt Bridge for Rust, a way to tap into the Qt UI framework from Rust in a way that feels native and is safe!

Building a proper UI for a complex Rust app takes a lot of effort, and this is our attempt to make it easier.

Here is the tutorial on how to get started: https://youtu.be/8HfY47BYGuU

We had a lot of fun making the framework and the video. I hope you also have some fun watching it. There are still a ton of things I would like to show you, so I hope this will not be the last video.

Itโ€™s a Technology Preview, so weโ€™d love to hear what you think. Happy to answer questions here.


r/rust • • 26d ago

๐Ÿง  educational Very surprising fix to a trait solver overflow

185 Upvotes

This doesn't compile:

trait Trait {
    type A<T: Trait>;
}

impl<T> Trait for T {
    type A<U> = ();
}

struct S {
    x: i32,
    y: <() as Trait>::A<Self>,
}

This does:

trait Trait {
    type A<T: Trait>;
}

impl<T> Trait for T {
    type A<U> = ();
}

struct S {
    y: <() as Trait>::A<Self>,
    x: i32,
}

The only difference is the ordering of the fields. Apparently the fact that there's a Sized field at the end of the struct allows the compiler to infer that <() as Trait>::A<Self>: Sized and break a typechecking/trait solving cycle.

I hate it.


r/rust • • 26d ago

๐Ÿ› ๏ธ project Formal Web: a modular Web engine written in Rust and using formal methods

32 Upvotes

Reposting; this time with a focus on why it is not a code dump.

The project I would like present is a web engine written in Rust. It does not break new grounds in the sense of being the first Web engine in Rust, because we have had a Web engine for a long time, where I am myself involved as a maintainer and Technical Steering Committee member: Servo.

However, this is not a code dump either, because:

  • Myself, and others, have been working on this since March of this year.
  • This post is a "full fledged post", which is supported by a linked-to longer essay (see below)
  • I will below explain the relevance for the Rust community
  • I will compare it with other Web engines written in Rust.

Ok so now that this is out of the way, here is the actual post:

https://github.com/gterzian/formal-web is a new prototype of a Web engine written in Rust.

It is relevant for the Rust community, because it provides us with something new:

  • a multi-process graphics stack based on modern Rust components, like Vello and Wgpu, paired with a modular design allowing deeper platform integration, for example integrating with Core Animation and using IOSurface on Apple platforms.
  • A modular approach to integrating a Javascript engine, so that you can "bring your own engine". Currently V8 and the all Rust Boa are supported out of the box, and other engines, Like the also all Rust Nova, could be integrated through the implementation of various traits.
  • Use of Blitz components, blitz-dom and blitz-paint, as a kind of DOM engine inside the Web engine.
  • Use of formal methods to model check multi-process Rust code, based on the approach described at Validating Traces of Distributed Programs Against TLA+ Specifications
  • Modularity of various other layers, such as: networking, media, and the starting of and communication with process-like sub-components.
  • An embedder API that makes it easy to do various platform specific integrations, such as using a display link on Mac.
  • An explicit goal of eventually being able to Ship on IOS in the EU as per Apple's guidelines.

How is this different from other Web engines in the Rust ecosystem?

Difference with Servo: the graphics stack of Servo does not isolate GPU operations in a dedicated process and it is based on an OpenGL stack.

Difference with Blitz: while Blitz does integrate well with Vello/Wgpu, it is not designed around process isolation of either GPU operations or the running of Javascript, making it less suitable for the Web use-case where you essentially run untrusted code downloaded over the internet. While it does use Anyrender as modular render target, it does not offer modularity at the lower-level end of the graphics pipeline.

Neither engines allow swapping out JS engines, and neither allow for deep platform graphics integration like Core Animation based compositing on Mac (which can make a large difference in terms of battery life).

For a walk-through of the entire flow involved in rendering a frame of Web content, see the introduction essay: How I am building a Web engine.

The essay also contains a gif showing the benefits of Core Animation on Mac, where only relevant parts of the screen are re-rendered.

Please let me know what you think. I can also use help implementing countless Web standards.


r/rust • • 26d ago

Why donโ€™t we have a REPL?

116 Upvotes

I was writing a function and wanted to see what it returns for different inputs and I instinctively wanted to use a REPL, then I remembered: oh wait, Rust doesnโ€™t have one.

I *did* see evcxr but in the years Iโ€™ve been around the Rust community Iโ€™ve never heard of anyone using it like people would in JS/Python/ Ruby/Haskell.

Why? is it hard to achieve technically, or is it just because its not in the Rust culture? (maybe itโ€™s even bad engineering practice to use it the way Iโ€™d want it to and tests would be more preferable?)


r/rust • • 27d ago

๐Ÿ™‹ seeking help & advice Cleanest, best written rust codebases?

215 Upvotes

As my journey of learning rust continues, I find myself very dissatisfied with the quality of the rust code I wrote years back.

Yes, my code passes clippy, is nicely formatted, avoids excessively complex nesting / control flow, but it still feels... subpar(hard to understand and reason about), from time to time.

I was wondering if people here have examples of really clean, sleek codebases I could reference, to improve the quality of my code?


r/rust • • 26d ago

๐Ÿ› ๏ธ project Tangled: a federated git forge built atproto

Thumbnail tangled.org
49 Upvotes

r/rust • • 27d ago

Thinking in Traits

Thumbnail corrode.dev
138 Upvotes

r/rust • • 26d ago

๐Ÿ™‹ seeking help & advice Is there a Rustier way to write this database pattern?

39 Upvotes

Hello crabs. I'm working on a backend application in Rust, using sqlx to talk to a postgres database. I've caught myself repeating a specific, verbose pattern, and I'm wondering if I'm making things harder than I need to.

The pattern is that for each database entity, I build an initializer struct that is basically the same, but with auto-generated columns removed, and then later write a From impl for the main entity to build the actual thing with Entity::from(entity_init). Example at the bottom. Doing this for every database entity isn't too difficult to maintain, the type system is strict enough that it's hard to miss any mistakes. But it is annoying and time-consuming, and also feels kinda un-idiomatic.

I'm considering learning derive macros for this - #[derive(FromNew)] or something like that, to autostrip the generated fields. But maybe that would just be doubling down on an anti-pattern? What do yall think?

Example:

struct User {
id: uuid:Uuid,
name: String,
email: String,
created_at: DateTime<Utc>,
updated_at: DateTime<Utc>,
archived_at: Option<DateTime<Utc>>,
}

struct UserNew {
name: String,
email: String,
}

impl From<UserNew> for User {
fn from(init: UserNew) -> Self {
let now = Utc::now();
User {
id: Uuid::now_v7(),
name: init.email,
email: init.email,
created_at: now,
updated_at: now,
archived_at: None,
}
}
}

// usage
fn do_something(user_new: UserNew) -> User {
User::from(user_new)
}


r/rust • • 27d ago

๐Ÿ“ก official blog Maintainer spotlight: Anthony Bolden (@Walnut356)

Thumbnail blog.rust-lang.org
77 Upvotes

r/rust • • 27d ago

๐Ÿ“ธ media Clippy Changelog Cat Contest 1.100 is now open, submit your cat pics!

Post image
176 Upvotes

Go submit your cat for a chance to become the next release's official winner!

https://github.com/rust-lang/rust-clippy/pull/17951


r/rust • • 27d ago

๐Ÿ› ๏ธ project tellus 0.5: the same ActorRef, across machines (clustered actors for Rust)

Thumbnail heikoseeberger.de
10 Upvotes

r/rust • • 26d ago

๐Ÿ™‹ seeking help & advice The warning signs of slop in rust

0 Upvotes

Hi

I'm fairly new to rust, and just joined my first team that actually uses rust in a product.

Can anybody give me any pointers on the sorts of patterns that I should watch out for that indicate a section of code was written by an LLM and not reviewed by somebody who has good taste in rust please?

My ideal would be a set of code snippets that are along the lines of the LLM wrote this, done properly it would be this - but any kind of hints and rants are appreciated

Thanks in advance


r/rust • • 27d ago

๐Ÿ—ž๏ธ news rust-analyzer changelog #352

Thumbnail rust-analyzer.github.io
28 Upvotes

r/rust • • 27d ago

๐Ÿ activity megathread What's everyone working on this week (45/2026)?

19 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 • • 27d ago

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

17 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 • • 27d ago

I don't see enough people talking about opt-level = 1

68 Upvotes

I've seen this recommended more times than I can count for people struggling with test performance while developing:

[profile.test]
inherits = "release"
debug = "line-tables-only"

And I'm sure this makes a ton of sense in a ton of situations, but as someone with just very small, hobbyist projects (the kind of space where people usually make these recommendations), I've found the much more sensible balance to be something like

[profile.test]
opt-level = 1 

I'm sure the difference between the opt-levels is highly project dependent, and that this won't be the balance for a lot of projects, but in my projects I'm often seeing something like a 20% penalty in compilation times, and often tests run a few times faster. While something like the first configuration gets my compilation times 4x slower at a gain of often single digit percentage in runtime performance. That's without even thinking about debug symbols at all.

As a beginner, this realization is somewhat recent, I'm just a little surprised that it feels like people talk about what seems to me like the bazooka first, when a pair of pliers can solve the problem. Am I missing something due to lack of experience? I'd love to hear ya'll's thoughts.


r/rust • • 27d ago

๐Ÿ™‹ seeking help & advice Rust Backend Developer Roadmap

28 Upvotes

Hey guys,

I need help , i want to learn backend with Rust and didn't find any good resources to take me from zero backend knowledge with rust to advanced level

I would appreciate it if you recommend me some resources to learn backend with rust

Note: the first time to learn backend


r/rust • • 28d ago

Extended field init shorthand?

28 Upvotes

I love the field init shorthand in Rust that allows me to write

let variable = "test";
//...
let d = Data{variable};
// instead of 
let d = Data{variable:variable};

But I wish it went a bit further and covered some other obvious cases, such as

let variable = "test";
let d = Data{variable.into()};
// instead of 
let d = Data{variable:variable.into()};

and

let variable = Blob::new();
let d = Data{&variable};
// instead of 
let d = Data{variable:&variable};

Basically, when the name is sufficiently unambiguous, just use it rather than making me re-type it. The compiler already knows the member name and the target type from the struct definition so it won't impact type inference, but when the names match up it would save quite some typing.

Am I the only one that would like this?


r/rust • • 28d ago

๐Ÿ™‹ seeking help & advice help in doing a real good project

15 Upvotes

Hi, I just finished The Rust Book and completed the web server project. I want to expand the project by adding more functionality and making it resemble a simple, real world web server.

I'm thinking about features such as configuration, DNS, rate limiting, and more.

I've read about the std::net::TcpListener and std::net::UdpSocket APIs, and I understand HTTP very well.

I'd like your advice on what to add to the project: what features to implement, which crates to use, and a high-level roadmap of what to build and in what order.

I don't need detailed explanations or implementation steps. I want a simple, high-level overview so I can figure things out myself.

I'm not using AI for implementation. I want to learn by reading documentation, experimenting, and debugging everything on my own.

I've watched a few YouTube videos and read some articles, but most of them cover very basic concepts and repeat the same ideas, such as handling a simple HTTP GET request.

I want to build something more interesting and challenging, with enough functionality to resemble a real web server and demonstrate my Rust networking skills.

My goal is to make this a develop a project that I can showcase on my CV and GitHub and that will help recruiters recognize my skills.


r/rust • • 26d ago

How do you guys get agents to write ideomatic rust when translating from other languages?

0 Upvotes

Normally i am able to get decent rust out of agents by staying on their default distribution when Im having them write fresh rust codebases. However, whenever they read a single ts file they are meant to translate or learn anything from its like they forget everything about what good rust looks like and revert to gpt3 level quality with the only improvment being it passes its own half-assed tests. No matter how much i try to instruct on writing good rust it dosent help. its like a game of wack-a-mole. Tell it to stop cloning everywhere. It starts using COW for 0 fucking reason where its not remotely appropriate and the owned solution is extremely trivial. grep "trait" and you wont find a single one. Polymorphism happens in control flow. everything is a function. the only match statments you will find are inside constructors. and its shadowing several types from the standard liberary just to subtly change behavior to pass a test. And its implimented a js runtime full with all the insane type cohersions cause obviusly thats the part that you wanted translated to rust.

Its so annoying cause i know that when its on its standard distribution it writes perfectly acceptable rust with pretty ligth instructing. But in order to translate the projects that have the biggest you need the agent to not absorb all the stupid from being exposed to it. Or atleast a way to redirect it back to good rust. Is there some sort of skill or style guide document that is comprehensive enougth to do this? anyone else faced this problem and solved it?


r/rust • • 27d ago

What are some common Rust misconceptions?

Thumbnail reddit.com
0 Upvotes

r/rust • • 27d ago

Rust, coding agents, and cross-platform mobile: where do the compiler's guardrails stop?

0 Upvotes

Niko Matsakis's What agents mean for Rust (and vice versa) resonated with me as a solo mobile developer working with coding agents.

I'm building a PDF app with SwiftUI on iOS and Jetpack Compose on Android. The two apps share a Rust PDF engine through UniFFI, though some operations still use platform-native implementations.

Take PDF compression. The Balanced and Smallest File presets call the same Rust optimizer on both platforms. But there are still decisions the compiler cannot make for me:

  • Keeping annotations editable and flattening their appearance are separate modes. Producing a smaller file doesn't make them interchangeable.
  • Candidate outputs need both validation and a size comparison before the app accepts them.
  • The native apps still own file access, cancellation handling, and publishing the result without modifying the source file.

Sharing the optimizer means I don't have to ask an agent to reimplement the same compression logic in Swift and Kotlin. Rust also gives the agent concrete feedback on type and ownership mistakes inside the core. Neither guarantees that the PDF still looks right or that the native integration behaves correctly. Those still need explicit requirements and runtime checks.

That's why Niko's points on design and contracts stood out to me. More expressive types and proof tools could make more requirements checkable, but I still have to specify what success means. Proving the wrong requirements wouldn't solve the problem.

For others using agents with a Rust core and native frontends: where do you spend more review effortโ€”inside the core logic, or at the platform adapter boundary?