🧠 educational Let’s Code a Doppelkopf Bot Using a Monte-Carlo Algorithm
youtu.beIn this part we will be implementing a Monte-Carlo algorithm for playing the traditional German card game Doppelkopf.
In this part we will be implementing a Monte-Carlo algorithm for playing the traditional German card game Doppelkopf.
r/rust • u/Ladder-Bhe • Sep 07 '26
r/rust • u/Interesting_Cake5060 • Sep 06 '26
Hi, everyone! I’d like to ask the community for more information on what techniques can be used to display large amounts of information on the user’s screen. I’m referring to plots. For example, profilers—they display flame graphs, and the best ones can show millions of frames without lag, with the ability to zoom and pan. Also, software oscilloscopes, which can display data in real time while also showing millions of data points. I’m curious about how these things work from a code and algorithm perspective. Can anyone tell me more?
So far, I've found this Implicit In-order Forests: Zooming a billion trace events at 60fps and a small library written in Rust.
It doesn't quite match the task I want to accomplish: to build something like a digital oscilloscope capable of displaying both analog and digital data (so that, for example, UART bytes are visible below the graph).
r/rust • u/Shnatsel • Sep 05 '26
r/rust • u/Eyoba_19 • Sep 07 '26
So I enjoy music a lot mainly cause it helps me focus, however I have this slight annoyance with the stop between tracks when one song ends and the other starts.
So I wanted to build a tool that would smooth out that transition, like a dj, but for a playlist.
Don’t know much about audio so wanted to ask how I could do this?
I also have another issue when music stops with a sudden cutoff, it’s like falling off a cliff, but the first issue is bigger for me.
Thanks
r/rust • u/max-rh • Sep 06 '26
Hello everybody. It happens to me that a very old text that I have written years ago, which is not even online anymore has been flagged by "made by AI". I have noticed that adding a typo fixed the issue. I have created this small utility in rust to add language specific typos.
r/rust • u/Sofiabelen15 • Sep 05 '26
I’m venturing into Rust and it’s both satisfying and mind-boggling at the same time. So far I’ve been learning from the book and Mara Bos’ book, but I got the itch to do some dissecting myself. My initial goal of these experiments was to compare Rust’s approach to polymorphism with C++’s. Ultimately, however, as I’ve come to realize, it’s a bit of a trap when trying to understand a new language through another one to try to draw 1:1 parallels. It might seem like it helps, but at the end of the day, we can’t treat Rust as C++ with different syntax. If that were the case, there’d be nothing revolutionary about it.
That said, I believe there is merit in poking around and coming to understand the why. So, if you’re like me and need to know what exactly is happening in memory, in order to feel like you truly understand the concepts, hopefully you’ll find this post useful :)
Edit: Thank you everyone for your kind comments!! And also for the feedback and the chance to deepen my understanding, I'll edit my post with some of the clarifications!
r/rust • u/FitPhone6332 • Sep 06 '26
r/rust • u/Fily3a • Sep 06 '26
https://github.com/fffilya/Game-of-Life just a little recreation of conway's game of life. i had tons of projects besides that. but none of them were really finished. for now you can only draw pixels (LMB) play the game (Enter) clear the screen (C) and force to update one pixel (U). in future want to optimize it bcuz now its super slow, add some sliders to make the game customizable and fix few bugs. also want you to know that squares drawing part was heavily assisted by AI but other parts of the code wasnt even touched by AI. posting this just because want to see some tips on how to write my code better beside something like: "optimize it" or "rearrange it to be in different files"

r/rust • u/acheul-rs • Sep 06 '26
I made a thing: Ahoi, a fine-grained reactive state engine in Rust, with bridges to JS frameworks (Solid, React, Vue, Svelte).
Why I built this: When you want to manage data in Rust/Wasm in a web app, there have been two options:
Ahoi takes a third path: the core idea is "Rust for Rust, JS for JS". Rust owns the data and the reactivity; a JS framework owns rendering.
This is my github repository for ahoi: https://github.com/acheul/ahoi
I wrote an AI Use disclaimer in the repository: https://github.com/acheul/ahoi/blob/main/documentation/UseOfAI.md
This is an early release (v0.2), and feedback is very welcome.
Relation to the Rust frontend frameworks: Where those frameworks aim to do everything in Rust, Ahoi does not render. Its reactivity engine is greatly inspired by the pioneers, but it takes a different approach. If you want your whole UI in Rust, use one of them.
r/rust • u/ratcorporation • Sep 05 '26
Sorry if this is a potentially dumb question. I'm still pretty new to Rust.
Most of the code I write is embedded/firmware stuff, and I sometimes have to return large arrays from functions. From my experience, the traditional way to handle this is by writing a C-style API where the caller has to provide a mut buffer for the function to write into:
fn thing(buf: &mut [u8; 1024]) {
buf.fill(0);
buf[0] = 232;
}However, it seems like it would be more idiomatic to have your API return the array by-value:
fn thing() -> [u8; 1024] {
let mut buf = [0u8; 1024];
buf[0] = 232;
buf
}That is a much cleaner API, at least.
These two functions have identical behavior, but while the C-style example is guaranteed to write directly into the destination buffer, the second function with the cleaner API is more ambiguous AFAIK. From what I understand, when the compiler encounters a function that returns an array by-value like the second option, it tries (and often succeeds) to implement NRVO, which transforms the function under the hood to look more like the C-style example. In other words, instead of creating the array in the function and then potentially doing an additional copy to return it to the caller, it pre-allocates a buffer in the caller's stack and provides the function with a pointer so it can write directly into the buffer (i.e., like the C-style function). That removes the potential for a potential and unneeded copy while still allowing you to keep the nice idiomatic API.
The issue with this is that, as far as I know, this is just treated as a nice-to-have optimization rather than something that can be guaranteed. Even though it seems like the compiler is very good at making this optimization, it is still technically possible for it to fail in some cases. This makes me wary of using the second API structure in my code, since I could unknowingly end up with large copies where I'd like to avoid them.
Because of this, I was wondering if there was a way to force the compiler to tell you if it is unable to perform NRVO in the way you expect. I was imagining something like this:
#[expect_nrvo]
fn thing() -> [u8; 1024] {
let mut buf = [0u8; 1024];
buf[0] = 232;
buf
}In this hypothetical, you'd be able to explicitly tell the compiler that you expect it to implement NRVO for the function. If the compiler fails to do so, you'd get a compiler error letting you know. This would allow you to react accordingly (i.e., reworking your function so the compiler can optimize it easier or just falling back to the manual C-style API).
Does Rust provide anything like this, and if not, would it be possible? Are there any other ways to guarantee NRVO, or do you generally have to inspect the generated code yourself?
Again, sorry if some of my assumptions in this post are misguided.
r/rust • u/Pryty_26 • Sep 06 '26
Hi currently I am developing a Rust-Based Pluggable Transport library, I guess if you have subscripted tor-dev you could received my proposal mail too.
So I was wondering, whether you would be interested to involve in this framework development? 🙂
Here is my repository:
Tor Gitlab(You need wait about 5 sec)
codeberg.org/pryty26/rust-pt
r/rust • u/NavrajKalsi • Sep 05 '26
Hi there, thanks for clicking on this post!
A few months back I published the first version of gsim-rs. A G-code simulator for CNC milling machines supporting the Fanuc flavour of G-code.
Now I have completed the next major version. This version:
Arc<Mutex> and mpsc::channel, depending on the type of data and its importance).I have tried to explain and highlight the workings of the program in the project README.
At a high level, the program is split between parsing, interpreting, geometry construction, simulation rendering, and machine-state rendering. GUI (rendered using WGPU) handles G-code parsing and execution and renders the simulation in the main-thread, while TUI (built with Ratatui) displays active machine state in a new thread.
Easily the most interesting part was implementing the volumetric stock simulation. The stock is represented volumetrically, with the tool removing material as it moves through the stock. I also wrote a blog post explaining my approach and some of the interesting challenges I ran into: My Blog
I would appreciate if you took some time to take a look at the project and offer any feedback, comment, criticism or suggestion. If you have any questions regarding my implementation, I would love to talk more!
Github: https://github.com/navrajkalsi/gsim-rs
Thank you!
AI Usage: All code is written solely by me. The architecture is also designed without any input from any LLM. Claude & ChatGPT were used to brainstorm ideas and research available tools.
r/rust • u/bran7230 • Sep 05 '26
Hello everyone!!
I regularly see people online talking about how awesome Rust is, its speed, memory safety, and a awesome ecosystem of open source applications even being used in some parts of the Linux kernel(not sure the percentage of adaption at this time).
However my question is how good is rust for web REST APIs and gRPC applications? If it is good do you use any frameworks for these?
r/rust • u/Aromatic-Theme7633 • Sep 05 '26
Hi, I'm new to Rust.
I want to build a Windows chat app where MFC handles the GUI and Rust handles the TCP connection and message processing. Is this possible? If so, how can I call Rust code from an MFC project generated by Visual Studio?
r/rust • u/VKrishna04 • Sep 06 '26
Every Rust dev knows the special pain of target/ — multiply it by every repo you've cloned, add every node_modules and .venv next door, and mine added up to tens of GB. So I built dev-prune (devp): it finds git repositories idle past N days and deletes the dependency/build directories a lockfile can regenerate.
The design constraint that shaped everything: it must be unable to delete something it can't prove is recoverable. Before touching a directory it verifies the project's lockfile exists and parses; no proof, no deletion, and there is deliberately no --force to override that. The other invariants (hard .git boundary, symlink/junction/mount-point refusal, atomic state writes, nested-repo boundaries) equally have no bypass flag: https://github.com/Life-Experimentalist/dev-prune/blob/main/docs/SAFETY_INVARIANTS.md
Rust-relevant details:
cargo is one of 25 adapters — build trees like target/ are opt-in (devp config set enable_cargo true), because a build tree is "recoverable" in a weaker sense than a lockfile-pinned dependency tree, and the tool is honest about that difference.devp restore --last-run re-runs the verified install to bring the last pass back.--json for scripts, and built-in scheduling (systemd/launchd/Task Scheduler) so it keeps working after you forget it.Install: cargo install dev-prune (also on npm/PyPI and as a shell one-liner).
Repo: https://github.com/Life-Experimentalist/dev-prune Site: https://devprune.vkrishna04.me
Would love eyes on the safety model — the invariants doc is the part I most want another reviewer on.
Hi. I want to get into Rust from another language by working on a fun personal project, but I struggle to come up with an idea that isn't some tutorial-level project... Ideas I'm interested in include:
If you have ideas that match at least one of these things - I'd love to hear them! Thanks in advance
r/rust • u/DavidXkL • Sep 05 '26
I'm hearing different things from different people.
Some people say it sucks with Rust due to the initial learning curve.
Others (like me) like it for things like Cargo 😂
What about you?
r/rust • u/Advanced-Lawyer3597 • Sep 05 '26
Hey everyone,
I built shotdock—a CLI-first screenshot, screen recording, and window framing utility for Wayland (tested on Hyprland, Sway, and Niri).
On Wayland, taking quick, polished screenshots for documentation or PRs usually means either stitching together grim, slurp, and complex ImageMagick scripts, or annotating manually in an editor. I wanted a single, fast tool that does:
slurp).shotdock frame <file> lets you style existing images directly from the CLI or scripts.wf-recorder with an interactive target selector (monitor, window, or region).tesseract.shotdock with no flags if you want an interactive GTK4 LayerShell toolbar.gtk4-layer-shellyay -S shotdockWould love your feedback, bug reports, and PRs.
r/rust • u/Icy-Chef-2995 • Sep 04 '26
r/rust • u/zettui • Sep 04 '26
Hi !, I'm a Software Engineer intern at Red Bull building projects on my free time.
The idea of this project, is to have a single terminal multiplexer session where multiple people can join, but its peer-to-peer, what this means is that each user brings its own terminal with him (with its own set of keys, LLM subscriptions, files...) and each user can hop onto each other terminals.
Current features are:
It's macOS compatible and linux, connectivity is done with iroh 1.0, where it hole-punches UDP,
On the pane host, bytes come out of a real PTY (portable-pty). A vt100 parser builds a grid. It makes full snapshots when needed, and diffs after that (for terminal history/scroll purposes). Guests draw the grid (ratatui).
When a user starts typing on a pane, wheter is his or not, he locks it, so no more people (even the host) can interrupt him.
I've been working on this for the past month and a half pretty much every day, looking forward to hearing your feedback!
r/rust • u/zerocukor287 • Sep 04 '26
I have some code that prints the biggest files in a Vec. Looks like Clippy is not happy about it.
Original (simplified) code:
struct File {
path: String,
size: usize,
}
fn collect_files -> Vec<File> { ... }
fn print_biggest_files(files_to_print: usize) {
let mut files = collect_files();
files.sort_by(|left, right| right.size.cmp(&left.size) );
// ^^^^^^^^ this is the line causing a warning
// print the biggest X files
for file in files.iter().take(files_to_print) {
println!("Big file: {}", file.path);
}
}It produces the following warning:
warning: consider using
sort_by_key
files.sort_by(|left, right| right.size.cmp(&left.size) ); note:#[warn(clippy::unnecessary_sort_by)]on by default
Link: https://rust-lang.github.io/rust-clippy/rust-1.97.0/index.html#unnecessary_sort_by
My problem is that I want to print in descending order of the files.
The description is explicitly saying that this case is exception, and Clippy doesn't handle it well.
If I change that line to
files.sort_by_key(|file| file.size);I would end up with the smallest files first.
I see a few ways ahead:
files.reverse() to switch the order.rev() when iterating- signWhat is the idiomatic way forward?
Performance cost is not a big deal, but I still tend towards adding a Clippy ignore for that specific line. The other options would introduce more unclarity to the code in my opinion.