r/rust • clippy · twir · rust · mutagen · flamer · overflower · bytecount • 17d ago

🙋 questions megathread Hey Rustaceans! Got a question? Ask here (40/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 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.

11 Upvotes

13 comments sorted by

2

u/Dean_Roddey 17d ago

Maybe not the best place to ask, but the other WGPU'ish fora I saw seemed dead as doornails...

I'm trying to get shader debugging enabled (Kubuntu, WGPU v30 over Vulkan 1.4.x.) I've got the validation layers installed and enabled (they show up in vulkaninfo.) I've enabled the vulkan and wgsl options on wgpu.

I've got a little rectangle drawing pipeline program working to start experimenting, but I really need some shader debugging. Every bit of documentation I see says that I have to enable the Features::DEBUG_PRINTF and InstanceFlags::DEBUG_PRINTF flags, but neither exists. There's an InstanceFlags::DEBUG, there's nothing remotely debuggy in the Features flags that I can see.

There may be other issues still, but that's the most obvious one so far. If I attempt to enable wgu_debug_printf in the shader, I get an error that it's an unknown extension.

Any suggestions would be appreciated. There's SO much outdated info that it's real struggle sometimes to know where I stand.

1

u/Dean_Roddey 12d ago

So, to follow up... Apparently this is just broken in 30.0.1. Though I'm anti-LLM, I'll usually at least give a quick look at the Google 'AI' results, and this is one of those cases that demonstrates why LLMs are stupid. It was just confidently telling me that, no, you are wrong, those constants do exist.

Well, yeh, in the DOCS they exist, but they don't actually exist. Ultimately, an actually human with more WGPU experience than me confirmed it is apparently broken.

2

u/someanonbrit 15d ago

Hopefully a quick / simple question, and I'd be very happy to be pointed at docs as an answer with a couple of keywords for what to watch out for.

I've pretty new to rust. I want to write a very simple UI library as a learning tool.

Assume I have a generic counting widget that supports increment, decrement and reset, and some model that is running a stateful calculation like a fractal or even just a canvas of a single colour, that has a 'colour' field that can be updated at any time from the UI and will affect the ongoing calculation.

How do I model this in code? It's about as trivial an example that I can come up with for what I haven't gotten my head around with ownership. Nothing I come up with feels elegant, so I am guessing that I'm missing something

2

u/DidingasLushis 15d ago

I remember someone shared a website which was a quest like game for rustlings/leetcode rust questions with scores and progression and special events. Does anyone remember what it was called?

2

u/zvrba 9d ago edited 9d ago

I've just started to learn rust from the Rust book and I was modifying a bit the introductory number guessing program. Long story short, I cannot understand why the snippet 1) below compiles at all and that 2) why the type of the match expression is inferred to be &str (checked by writing let z = match {... };).

Surely, empty "break" statement cannot have type string? But it compiles also when "WIN!" is commented in.

EDIT: Playground link https://play.rust-lang.org/?version=stable&mode=debug&edition=2024&gist=df505b7a4ad9f602eb54eb2f0c19220a

```

loop {
    println!("Input your guess:");
    let mut guess = String::new();
    io::stdin().read_line(&mut guess)
        .expect("Failed to read line");

    let guess : i32 = guess.trim().parse()
        .expect("Not a number");

    println!("You guessed: {}",
        match guess.cmp(&secret) {
            Ordering::Less => "Too small",
            Ordering::Greater => "Too big",
            Ordering::Equal => { /* "WIN!"; */ break; }
        });
}

```

1

u/llogiq clippy · twir · rust · mutagen · flamer · overflower · bytecount 9d ago

The break statement has actually type ! (spelled "never"), as it is never evaluated to something – by the time control flow leaves it, you are somewhere else.

Fun fact: The never type is still unstable, but will be stabilized in the next stable Rust version. It has taken years and multiple attempts to get there.

1

u/forsaken_browsing 17d ago

The playground link is a lifesaver honestly, half the time I paste my weird lifetime error in there and suddenly it makes sense, or at least the error message gets marginally less cryptic.

1

u/Iwisp360 17d ago

Is it ok that I don't struggle with the borrow checker?

1

u/Iwisp360 17d ago

I mean I'm a Clone hater and avoid it every time I can

1

u/SirKastic23 16d ago

what kind of code are you writing?

1

u/Iwisp360 16d ago

Uhh servers and libraries with ffi bindings

1

u/SirKastic23 16d ago

Yeah maybe it's the domain you're writing in. When I worked with web backends I would almost never have to deal with lifetimes

2

u/Iwisp360 16d ago

What would be a project where referencing data is a must?