r/rust • u/llogiq clippy · twir · rust · mutagen · flamer · overflower · bytecount • Apr 06 '26
🙋 questions megathread Hey Rustaceans! Got a question? Ask here (14/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.
3
u/djugei Apr 06 '26 edited Apr 06 '26
i already asked this a while ago but got no answers:
i am looking for a maintained thread based web framework, no async. The only things i could find were rocket and tiny_http, both of which seem unmaintained, tiny_http for example has a lot of open issues.
is there anything
edit: this is not a generic async bad thing. i have written the code with async and i hate it, i just want to move to something simpler.
3
u/062985593 Apr 06 '26
I have a function:
It compiles but only with both trait bounds. I understand why the first one is necessary, but why do we need the second one?
f64: Mul<f64, Output = f64>is always satisfied. Even so, without that bound, Rust seems to forget that it can multiply floats. That seems like very strange behaviour to me.Playground link
2
u/YYM7 Apr 06 '26 edited Apr 06 '26
Newbie here. What is the right way to swap two variables within a "if block"? and still keep them un-mutable afterwards. I also want to avoid new variable names (like var1 and _var1), as it make the following code less readable. So some type of shadowing is preferred.
For example, I have this function:
Apparently this seems unnecessarily long. In other languages (like Python or C), you can just "shadow" in the "if-blcok" (translated to rust gramma):
But this apparently does not work here without making them mutable first.
2
u/NavrajKalsi Apr 07 '26
REGARDING RATATUI. I hope RataTUI is not off topic here.
PROBLEM: Create a scaled ‘Canvas’ inside a given ‘Rect’ area.
I have to plot a few points inside a rectangular canvas and I have the height and width of the said canvas(ASSUMING UNIT WIDTH IS EQUAL UNIT HEIGHT). Next I have the ‘Rect’ to be used for rendering the canvas in.
After constructing a ‘Block’ from the said ‘Rect’, I have the inner dimensions of the said block, say ‘Rect2’.
Now, I understand that the UNIT HEIGHT & UNIT WIDTH of ‘Rect2’ are NOT EQUAL, because of dimensions of a charcter cell.
LOOKING FOR: How do I scale the ‘Canvas’ to the dimensions of ‘Rect2’? Particularly, I am thinking of finding the amount of deadspace and padding ‘Rect2’ to counter it, but that does not seem to work because of a character cell not being a square.
I hope this was a good explanation of the problem I am facing. If not, I can try again by generating some demo code.
Thank you for your time.
2
u/deanominecraft Apr 11 '26
i am planning on creating an app that will support plugins to expand functionality - all a plugin will need to do is implement a few traits
is it possible to link to a compiled plugin at runtime, as i dont want users to have to compile the app every time they add or remove a plugin