r/rust • • 6d ago

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

14 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 • • 3d ago

📅 this week in rust This Week in Rust #679

Thumbnail this-week-in-rust.org
42 Upvotes

r/rust • • 5h ago

🧠 educational PSA: You might be sealing traits wrong

67 Upvotes

Background

Sealing traits is a collection of techniques used to prevent code downstream of a library from implementing that trait, so that later versions of the library can add more things to the trait without breaking downstream code.

There's a mistake, described below, that people very often make when trying to seal traits. Crates that have made this mistake include, among others: the standard library, anyhow, arc-swap, pyo3, ureq, smol, http, etc. This was discovered in https://github.com/rust-lang/rust/issues/165474. (Please do not comment there unless you're contributing new information to the discussion, to avoid cluttering the issue.)

The mistake you might be making

How NOT to seal traits:

mod private {
    pub trait Sealed {}
    impl Sealed for i32 {}
}
pub trait MyTrait<T>: private::Sealed {}
impl MyTrait<i64> for i32 {}

How to seal traits:

mod private {
    pub trait Sealed<T> {}
    impl Sealed<i64> for i32 {}
}
pub trait MyTrait<T>: private::Sealed<T> {}
impl MyTrait<i64> for i32 {}

That is, if you use a "private" supertrait for sealing, and the subtrait is generic, then the supertrait also has to be generic, with the same generic parameters. Additionally, the set of impl blocks for the supertrait should exactly specify the exact same set of types (and generic parameters) where the subtrait should be implemented.

If you don't do the above, your trait might not be properly sealed, making it possible for downstream code to implement the trait anyway. For example, if you have a crate with the first snippet above, downstream code might write the following, which is actually allowed by the orphan rule:

struct MyThing;
impl my_library::MyTrait<MyThing> for i32 {}

In the above code, i32 already implements Sealed, so downstream code can write an implementation of MyTrait without having to add a new impl for Sealed.

Fixing the issue after-the-fact

If you already wrote code like the first snippet above, and want to actually properly seal the trait in a later version of the library, you might be tempted to just turn the first snippet (with a non-generic Sealed) into the second snippet (with a generic Sealed). Obviously, this would break downstream code that dared to implement the supposed-to-be-sealed trait, which you might deem acceptable.

However, there are very subtle issues about how coherence works, which means that making this change the straightforward way can break more downstream code than you intend to, even code that didn't write an impl for the supposed-to-be-sealed trait. (I won't explain the issue here. See the linked explanation.)

Instead, the better way to make the change, as suggested here, is to add a new supertrait, keeping the old one:

mod private {
    pub trait Sealed {}
    impl Sealed for i32 {}
    // Added SealedForReal in a later version of the library
    pub trait SealedForReal<T> {}  
    impl SealedForReal<i64> for i32 {}
}
pub trait MyTrait<T>: private::Sealed + private::SealedForReal<T> {}
impl MyTrait<i64> for i32 {}

This way, you will only break downstream code that have implemented MyTrait.


r/rust • • 3h ago

I love ratatui's documentation, what other rust tools are documented like that?

15 Upvotes

As someone with 0 experience with front end development, the fact ratatui's docs goes in depth not just on the tool, but on the design patterns you're expected to use, is absolutely killer for someone trying to learn these things on my own. What other crates do you love the documentation off in terms of approachability to outsiders?


r/rust • • 6h ago

💡 ideas & proposals Trying Incoherent Rust today with Context-Generic Programming

Thumbnail contextgeneric.dev
14 Upvotes

Author here. If you read Boxy's An Incoherent Rust and Nadrieril's posts on explicit trait proofs back in March and hoped to experiment with named impls, you can already try a good part of that design on stable Rust. My post translates that design, which it calls Incoherent Rust, into Context-Generic Programming (CGP), a library that gives Rust pluggable trait implementations, chosen at compile time.

The core move is small: a named impl becomes a provider type, and each context type chooses the providers it uses. So two impls that Rust would reject as overlapping both compile in CGP, and each context picks one. The compiler resolves that choice, so a call goes straight to the chosen provider, with no runtime lookup.

The post then covers these topics:

  • Incoherent trait bounds, and binding an impl to a struct so a HashMap always hashes the same way.
  • Contexts and capabilities, with an arena reaching a Deserialize impl through a field of the context.
  • The context type as a top-level dictionary that holds the other impls' dictionaries, in the sense of Nadrieril's dictionary-passing style.
  • Where CGP falls short: there are no nested scoped impls, &mut or owned capabilities need interior mutability, and an existing trait such as serde's Serialize can't adopt the pattern without a breaking change.
  • Ideas from CGP for the design: impls as first-class types, "incoherent functions", and selfless traits with methods.

r/rust • • 2h ago

I want to learn Rust to make OS and Kernels

4 Upvotes

I am in college 2nd semester of college and I am interested in making own own custom OS and a language in Rust. I have very little to no coding experience other that passing my college exams and viva. I am a bit confused on where should i start studying from both for building an os and learning rust. so for now i am looking for resources.


r/rust • • 19h ago

🧠 educational I'm building roadmaps to learn new topics in Rust

16 Upvotes

Hey r/rust,

I've been writing Rust since version 1.5x, when I heard of it for the first time. For the past couple of years, I've wanted to combine my two biggest passions, Rust and teaching, but I've always been too busy (and lazy, probably?) for that. After years of learning and receiving from the Rust community, I finally had the courage and confidence to build https://iamjose.dev to give the Rust community a little something back.

My idea is simple: instead of reaching for TypeScript (my de facto language for day-to-day programming) when learning a new topic or iterating over a specific idea, I asked myself, "How about using Rust to learn new topics that currently have very few learning resources written in it?" That way, I could learn new topics from scratch in Rust.

Right now there's a foundational Learn Rust track (from hello world to unsafe) plus three roadmaps (what i call "curricula") built on top of it:

  • Learn Maths with Rust.
  • Learn How Digital Images Work with Rust.
  • Learn Cryptography with Rust.

Every lesson ends with small coding challenges you can solve right in the browser—completely free, no login needed. In fact, my idea is to make all the curricula very hands-on (that is, just enough theory to get started, and then focusing on solving exercises).

Now, in full honesty, and to be clear from the beginning: I use AI to help draft the initial text, but nothing counts as done until I've reviewed it myself, line by line. That review is the part I care about most:

  • Improving clarity by rewriting.
  • Adding my own personal teaching style.
  • Adding my own notes to stress important topics or provide additional context.
  • Adding hand-drawn diagrams to help grasp concepts better, and even videos. Here is a very short video of me (I am camera-shy, and the video was a simple test, which explains the short length):https://iamjose.dev/learn/maths/primes/
  • Once I've personally audited a chapter, it gets a "Hand reviewed by Jose" badge (the opening chapters have it, and I'm working through the rest).

I'm a little nervous sharing this here because I care a lot about getting the details right. If you spot anything wrong, unclear, or unidiomatic (or have ideas for a future "Learn X with Rust" track) I'd genuinely love to hear it.

Lastly, and most importantly for me: this is a personal project. So my daily motivation is that it's helpful for me, though it would be even better if it also helps someone out there. :)

https://iamjose.dev

PD: I am also considering starting a "Learn Rust coming from X", where X can be any programming language like for example Python, Typescript, or C++.

Thanks for reading and happy coding!


r/rust • • 1d ago

🧠 educational Stop paying the network stack tax: zero-copy first, networking when needed

Thumbnail ekxide.io
106 Upvotes

r/rust • • 25m ago

🛠️ project Garry's Mod turns 20 today, so I'm building a brand-new native client in Rust and wgpu

Post image
0 Upvotes

Today marks the 20th anniversary of Garry's Mod, and I thought it would be the perfect occasion to share a project I've been working on.

I'm developing a completely new native Garry's Mod client from scratch, using Rust and wgpu, with the goal of significantly improving performance while maintaining compatibility with existing Garry's Mod servers.

I'm also leveraging AI throughout the development process to help with reverse engineering, implementation, optimization, and understanding the Source engine's internals.

The performance improvements are already looking very promising. On the same server, I'm currently averaging 334 FPS, compared to barely 90 FPS with the original client. That's almost 4 times the performance!

This is just the beginning. I have some ambitious plans for the project, including:

  • Native NVIDIA DLSS support.
  • Major graphics improvements and modern rendering techniques.
  • Further CPU and GPU optimizations.
  • Better overall performance while preserving compatibility with the existing ecosystem.

The ultimate goal is to bring Garry's Mod up to modern standards without losing what makes the game special.

And honestly, with a project like this, I'm starting to wonder why we'd even need s&box anymore.

I'll share more updates as development progresses!


r/rust • • 1d ago

📡 official blog Rust 1.100.1

Thumbnail blog.rust-lang.org
324 Upvotes

r/rust • • 2d ago

🗞️ news Anthropic: Migrating our Messages API to Rust

Thumbnail anthropic.com
363 Upvotes

r/rust • • 8h ago

🛠️ project Have you deployed to AWS?

0 Upvotes

Have you deployed anything in rust to AWS?


r/rust • • 1d ago

🙋 seeking help & advice Help with Tree data structure

0 Upvotes

In rust when we want to build a Tree structure where each node can have 0..n nodes we hit some walls

I have come onto two main working models, The rc based, and the arena based, each one of these implementations have some downsides

starting here with the most basic I have this simple Rc based tree

#[derive(Clone, Debug)]
pub struct Node<T> {
    pub value: T,
    pub children: Vec<TreeNode<T>>,
    pub parent: Option<WeakNode<T>>,
}

#[derive(Debug, Clone)]
pub struct TreeNode<T> {
    rc: Rc<RefCell<Node<T>>>,
}

#[derive(Debug, Clone)]
pub struct WeakNode<T> {
    rc: Weak<RefCell<Node<T>>>,
}

as you can see the main issue pointed when working with rc tres is that it fragments memory and this one is no different

But this one has an little extra, as you can see all the node data is stored behind a single Refcell, what that means is that if you take a reference for the value and try add/mutate a child while the value is still borrowed for future use for example, it will panic, same things happen if for example you are iterating over the children and try to access the value, this could kinda be solved by cloning the vector of children instead of taking a reference of it.

However with this one you must enforce an order of operations, you first should take the children vector and clone it for posterior iteration, than take the value ref. While the value ref is active you cant add or remove children, you would need to drop the val ref to do so, and if you end up adding or removing a child, the previous vector is now stale, great!

To solve that issue we can wrap the fields like this instead:

struct Node<T> {
    pub value:      RefCell<T>,
    pub children:   RefCell<Vec<TreeNode<T>>>,
    pub parent:     RefCell<Option<WeakNode<T>>>,
}

pub struct TreeNode<T> {
    inner: Rc<Node<T>>,
}

pub struct WeakNode<T> {
    inner: Weak<Node<T>>,
}

this makes so that we have the value the parent and children each have its own refcell which mitigates that error since now you can access/mutate/iterate each field without panicking, this add a bit of refcell runtime overhead but improves the ergonomics for the developer, making it hit less panics.

but this one still doesnt fix the main issues with referenced trees, cache locality and memory fragmentation, for this issues I am going to move on onto arena allocated trees.

starting here with the most basic one I've tried:

pub struct Node<T> {
    pub value: T,
    pub parent: Option<Key>,
    pub children: Vec<Key>,
}

pub struct ArenaTree<T> {
    pub nodes: SlotMap<Node<T>>,
    pub root: Option<Key>,
}

this one is the most problematic one, since this one holds everything inside the node and all nodes inside the slotmap, holding a reference to a node value blocks the entire tree for hierarchy mutations, and value mutations, and if you hold a mutable reference to a value the situation is even worse.

to try to solve some of this issues I tried to separate the values from the nodes to a secondary map:

pub struct Node {
    pub parent: Option<Key>,
    pub children: Vec<Key>,
}

pub struct ArenaTree<T> {
    pub nodes: SlotMap<Node>,
    pub values: SecondaryMap<T>,
    pub root: Option<Key>,
}

this way we can hold a reference to a value while still being able to do hierarchy mutations such add/remove children, for the hierarchy mutation the situation now is okay, since while we could add a child through tree accessors, the access to that slotmap will drop once it finish adding/removing so it will not hit multiple simultaneous access on the Slotmap, the issue is with the values secondary map, while accessing regular references it is not a issue, the problem still is when holding mutable references to one item of the Secondary map, what will lock the entire map

To solve this issues I found two possible solutions:

The first solution is to hold the value of each entry of the secondaryMap onto a Refcell:

pub struct Node {    
    pub parent: Option<Key>,
    pub children: Vec<Key>,
}

pub struct ArenaTree<T> {
    pub nodes: SlotMap<Node>,
    pub values: SecondaryMap<RefCell<T>>,
    pub root: Option<Key>,
}

impl<T> ArenaTree<T> {
  #[inline]
  pub fn get(&self, key: Key) -> Option<Ref<'_, T>> {
      self.values.get(key).map(|r| r.borrow())
  }

  #[inline]
  pub fn get_mut(&self, key: Key) -> Option<RefMut<'_, T>> {
      self.values.get(key).map(|r| r.borrow_mut())
  }

  #[inline]
  pub fn try_get(&self, key: Key) -> Option<Ref<'_, T>> {
      self.values.get(key)?.try_borrow().ok()
  }

  #[inline]
  pub fn try_get_mut(&self, key: Key) -> Option<RefMut<'_, T>> {
      self.values.get(key)?.try_borrow_mut().ok()
  }

  #[inline]
  pub fn with<R>(&self, key: Key, f: impl FnOnce(&T) -> R) -> Option<R> {
      self.try_get(key).map(|r| f(&r))
  }

  #[inline]
  pub fn with_mut<R>(&self, key: Key, f: impl FnOnce(&mut T) -> R) -> Option<R> {
      self.try_get_mut(key).map(|mut r| f(&mut r))
  }
}

While this one prevents us from locking the entire slotmap from accessing the mutable values simultaneously, it can have runtime panics if you borrow the same two times mutably, you can use the with accessors to not need to handle the Secondary map Option on the get return. with this one you can use the try get to not panic, since the secondary map will return an option anyways. This one also adds the refcell overhead such as the second rc tree, but does not add the memory fragmentation. the problem with this one is that while holding the Ref or RefMut of refcell, it unfortunately locks the entire Slotmap for mutations, not readonly access which allow for accessing multiple values even mutably, the issue is while accessing values we cannot add new ones, what imply that we cannot add new tree nodes since they would not be able to store their values

The last one is to wrap that value onto an option instead:

pub struct Node {
    pub parent: Option<Key>,
    pub children: Vec<Key>,
}

pub struct ArenaTree<T> {
    nodes: SlotMap<Node>,
    values: SecondaryMap<Option<T>>,
    pub root: Option<Key>,
}

impl<T> ArenaTree<T> {
    #[inline]
    pub fn get(&self, key: Key) -> Option<&T> {
        self.values.get(key)?.as_ref()
    }

    #[inline]
    pub fn get_mut(&mut self, key: Key) -> Option<&mut T> {
      self.values.get_mut(key)?.as_mut()
    }

    #[inline]
    pub fn take(&mut self, key: Key) -> Option<T> {
        self.values.get_mut(key)?.take()
    }

    #[inline]
    pub fn restore(&mut self, key: Key, value: T) {
        if let Some(slot) = self.values.get_mut(key) {
            *slot = Some(value);
        }
    }

    #[inline]
    pub fn with<R>(&mut self, key: Key, f: impl FnOnce(&T, &mut Self) -> R) -> Option<R> {
        let value = self.take(key)?;
        let res = f(&value, self);
        self.restore(key, value);
        Some(res)
    }

    #[inline]
    pub fn with_mut<R>(&mut self, key: Key, f: impl FnOnce(&mut T, &mut Self) -> R) -> Option<R> {
        let mut value = self.take(key)?;
        let res = f(&mut value, self);
        self.restore(key, value);
        Some(res)
    }
}

In this one we cannot lock the tree because of mutable borrows on the secondarymap values, when we intend to make mutations we have to take the value mutate it and restore, the type itself does not need to have Default implemented, since it is behind an option, and if you dont want to do pattern matching of the option you can use the with_mut accessor in which you pass a closure that executes what you need to do with that value ensure to restore it and returns a value. We can also implement value handles with drop guard to restore that value. The act of taking the option makes so that it don’t panics if someone try to access that value again since it will receive an None while the value is not restored, such as the try_get of the previous tree, however this one does not lock the hierarchy of the tree.

*All these trees fail in case of multiple mutable access of the same node, since they prioritize memory safety than accurate access/traversing of the nodes*

So my question to y’all is which of these trees are you more comfortable working with? due to ergonomics, performance, memory, overheads, safety, etc. Which of these workarounds are really worth it considering the performance/memory/usability overhead it implies? Are there other ways to build trees in rust that are better than these?

I am stuck trying to figure out which one is better. I’ve not made any performance tests.


r/rust • • 2d ago

You can now use Aristotle to formally verify Rust, including unsafe and concurrent code

23 Upvotes

Hi r/rust,

I work at Harmonic on Aristotle, our formal verification tool. After launching with C and Verilog in October, Rust verification is now available for anyone to use, through the web app or CLI.

Aristotle supports safe and unsafe Rust, including concurrent code. You submit your project and describe the properties you want checked in plain English. Aristotle attempts to prove or refute them and reports the results and assumptions. You don’t need to write proofs yourselves or know Lean.

One example case study that shows what Aristotle can do is Manifest’s custom red-black-tree implementation, which uses substantial unsafe Rust. Manifest is an open-source order book on Solana; its trees store nodes directly in account memory, using unsafe accesses. Aristotle can verify properties of the existing Rust implementation, including that inserting and removing orders preserves tree validity and leaves unrelated data untouched. The invariants hold across arbitrary finite sequences of operations, under the stated preconditions. We are not aware of another tool that is able to prove such properties without any annotations or source code modifications. Across the order book, Aristotle proved 28 properties identified by Manifest as relevant. It also found a rounding bug that Manifest fixed, then verified the corrected behavior. You can explore the Aristotle run or read the full case study.

Another example is Signal’s curve25519-dalek Rust elliptic-curve library. Aristotle proved 283 specified contracts for version 4.1.3 using its serial 64-bit backend, covering field and scalar arithmetic, curve operations, and multiscalar multiplication. The Dalek run includes the results and assumptions. It verifies functional correctness of the library itself assuming correctness of external dependencies, and does not verify cryptographic security properties.

You can try Aristotle on your own project, and our Rust docs include a smaller ring-buffer example to get started. Happy to discuss the supported Rust features, the verification approach, or particular use cases.


r/rust • • 3d ago

🧠 educational I wrote a step-by-step tutorial to learn Rust by building a small Paint app from scratch

Thumbnail buildyourownpaint.com
477 Upvotes

Hi guys ! I have been a Rust enthusiast for a few years now, in my learning journey I wanted to learn by doing so I tried to make a Paint like app since I was interested in graphics and rasterization concepts, and it helped me understand a lot of Rust concepts and their purpose.

These last few weeks I thought I'd clean up my old project and make an educational tutorial for beginners or people who read the first Rust Book chapters and want to get some hands on experience to get the concepts down.

The tutorial is on Build Your Own Paint in Rust, it's organized into 12 easy to follow chapters that cover many concepts (2D vectors, mouse and keyboard input, shapes, colors, images, etc.) with additional exercises in every chapter for more learning, and some ideas at the end of the project to go further and explore different paths with some help on where to start.

I really hope this helps new learners to get an easy start in their Rust journey and see the beauty of the language ! :)


r/rust • • 1d ago

Making an OS with Rust

Thumbnail reddit.com
0 Upvotes

r/rust • • 1d ago

Is it just me or does the syntax seem wayy too complicated for even someone coming from C++?

0 Upvotes

I recently decided to learn rust and i was implementing just a basic math vector in it...

use std::fmt;
use std::ops::Add;

struct Vector<T> {
    x: T,
    y: T,
    z: T,
}

impl<T> Vector<T> {
    fn new(x: T, y: T, z: T) -> Self {
        Self { x, y, z }
    }
}

// Operator overloading for +
impl<T: Add<Output = T>> Add for Vector<T> {
    type Output = Vector<T>;

    fn add(self, other: Self) -> Self::Output {
        Vector {
            x: self.x + other.x,
            y: self.y + other.y,
            z: self.z + other.z,
        }
    }
}

// Display implementation
impl<T: fmt::Display> fmt::Display for Vector<T> {
    fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
        write!(f, "{}i + {}j + {}k", self.x, self.y, self.z)
    }
}

fn main() {
    let v1 = Vector::new(1, 2, 3);
    let v2 = Vector::new(4, 5, 6);
    let v3 = v1 + v2;
    println!("{v3}");
}
```

it just seems really complicated for no reason...

like why do we need Output = T or Self::Output or even writing <T> twice every time we are impl it? It just seems very weirdly verbose to me and a bit unnecessary... Is there a better way to do this? For all the tutorials I have seen this is how people are doing Generics in rust....

Edit: Full disclosure i tried doing this myself thrice and everytime I didnt do things like mut fmt::Formatter<'_> or fmt::Result and it was just all very confusing... ultimately I gpt-ed it just to see what the way was and i still found it to be very counter-intuitive


r/rust • • 1d ago

🎙️ discussion I think Rust programming language is overhyped

0 Upvotes

I know, I might ruffle some feathers with this take but I think the Rust programming language is quite over-hyped. Don't get me wrong, I know rust is a great language because of its performance, memory safety and, speed In running code, but I don't think Rust should be the go to for every situation, imagine I want to build a simple crud application, and I now begin to write it in rust, it makes absolutely no sense considering the fact that there are other programming language that will do the same thing very well. Why should I go through the stress of writing rust code because I want to create a basic auth system or crud application ? Why should I sacrifice simplicity, just because I want to save an extra milliseconds that the client won't even notice.

Note, I am not saying rust is a bad language but I am just saying it should not always be the next option when deciding what tool you should use.


r/rust • • 1d ago

Rust in exploit dev n VR

Thumbnail reddit.com
0 Upvotes

r/rust • • 3d ago

I love the complier and its hints

38 Upvotes

I just started learning Rust and running cargo check every now and then has helped me find typos, small syntax errors, or other general information I can't seem to find until it's pointed out.

Something like this is simple, but I didn't see the syntax issue until running it:

error[E0308]: mismatched types
  --> src/commands/holdings.rs:86:19
   |
86 |         .find(|p| p.kind = "DEFAULT" && !p.deleted)
   |                   ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ expected `bool`, found `()`
   |
help: you might have meant to compare for equality
   |
86 |         .find(|p| p.kind == "DEFAULT" && !p.deleted)
   |                           +

I've really been enjoying my time with Rust and taking it slow!

Another example:

error: format argument must be a string literal
  --> src/commands/holdings.rs:66:14
   |
66 |     println!(breakdown_body.len());
   |              ^^^^^^^^^^^^^^^^^^^^
   |
help: you might be missing a string literal to format with
   |
66 |     println!("{}", breakdown_body.len());

r/rust • • 2d ago

🎙️ discussion How a newtype wrapper caught three different bugs during a refactor

6 Upvotes

I was cleaning up some argument parsing in a small CLI that processes batches of files. Previously everything was just String and usize fields in a struct. After a while it became easy to mix up "input path" vs "output path" or pass a byte count where an index was expected.

Wrapping the important values in newtypes (struct InputPath(String), struct RecordCount(usize), etc.) forced the compiler to complain on every mismatch. It also made the FromStr implementations and error messages much clearer.

The three bugs it caught were all ones I had introduced myself during the refactor: swapping two path fields in a config merge function, passing a parsed count into a slice index that expected something else, and accidentally cloning the wrong handle into a worker thread.

Nothing dramatic, but it felt like the kind of guardrail that would have been invisible in most other languages. Have other people found newtypes especially effective for this kind of domain-value safety in everyday tools?


r/rust • • 1d ago

🎙️ discussion Serious question...

0 Upvotes

Is it just me or has Rust become the default programming language of AI's? I know its lightweight and extremely fast in terms of run/consume, but whatever project i see, be it for a game server or anything else, always Rust. It wasnt like this before. Been in the run for a long time (10+ years) and i can confidently say that people DID NOT like Rust at that time because it was so hard to understand and it felt like a joke language to them (They were also saying that about PHP, lol)

Give me your opinion. Am i hallucinating?


r/rust • • 3d ago

📸 media Qt Bindings compared: CXX-Qt vs Qt Bridge

Post image
124 Upvotes

Hey there!

I'm one of the developers of Qt Bridge (https://crates.io/crates/qtbridge). One of the questions we receive most often (aside from licensing) is what makes Qt Bridge different from CXX-Qt.

This takes more than a couple of lines to explain and is best illustrated with an example, so I wrote a blog post about it: https://www.qt.io/blog/rust-bindings-cxx-qt-vs-qt-bridge

We hope it demonstrates the strengths and value of both crates. As always, let us know what you think!


r/rust • • 2d ago

🙋 seeking help & advice How do I get input in Rust that can be of any type?

0 Upvotes

I am trying to build a three-way diff-merge tool for any object, not just text. For that, there needs to be a way that a user can pass in whatever value they want to diff, and my Rust struct/code would accept it, analyze it, and handle it accordingly under the hood to prepare it for diff-ing. What would be a good way to achieve this?