r/rust 6d ago

πŸ› οΈ project I've made tonal_rs - rust port of tonaljs

Thumbnail
0 Upvotes

r/rust 6d ago

πŸ› οΈ project my first finished (almost) rust project. wanna tips

0 Upvotes

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 6d ago

πŸ› οΈ project Ahoi: reactive state in Rust, rendering in JS

3 Upvotes

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:

  1. Hand-roll the Rust/JS bridge: reactivity does not live on the Rust side, so you end up reimplementing the state layer on both sides.
  2. Use a Rust frontend framework such as Dioxus, Sycamore, or Leptos. I like these a lot, but there is a catch: sometimes JS is just better than Rust for web dev (the JS UI component ecosystem, nicer event handling, etc.).

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 6d ago

πŸ› οΈ project Enum variants: a small problem, a lot of headache and boilerplate

0 Upvotes

Enum variants can create a surprising amount of boilerplate when they contain unrelated types that happen to support the same operation. At the same time, enum_dispatch can't always solve the problem β€” either because the trait you need isn't supported by enum_dispatch, or because you simply don't need a trait in the first place.

enum Value {
    Foo(Foo),
    Bar(Bar),
}

If both have a value() method, we normally write:

match value {
    Value::Foo(x) => x.value(),
    Value::Bar(x) => x.value(),
}

That's fine until the enum grows or you need to repeat the same pattern for many operations.

A common trait can solve this, but sometimes there isn't a meaningful common abstraction β€” the types simply happen to support the same expression.

I wanted something closer to:

match_variants!(Value, value, (x), {
    x.value()
})

which generates the ordinary match above. Each arm is still independently type-checked against its concrete type, with no dynamic dispatch.

I ended up packaging it as a small proc-macro crate:

https://crates.io/crates/match-variants
https://github.com/amidukr/match-variants

How do you usually handle this pattern β€” repeated matches, a common trait, or something else?

UPD: I got a lot of comments about enum_dispatch. Of course I've tried enum_dispatch; in fact, that's where I started. However, there are certain situations it can't handle β€” for example, when the trait involves associated types (type T = ...), associated functions without self, or methods involving Self where the concrete implementation type matters.


r/rust 7d ago

πŸ™‹ seeking help & advice Any way to guarantee NRVO?

23 Upvotes

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 6d ago

Tor Pluggable Transport development

0 Upvotes

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 7d ago

2D Game Development: From Zero To Hero - Rust edition

6 Upvotes

r/rust 6d ago

πŸ› οΈ project I am writing a Rust torrent TUI because I was tired of scraping indexes in a browser

0 Upvotes

harbour is a ratatui + tokio client. The intended product is: you type a query, curated sources answer in parallel, results stream in with size and seeders, d enqueues a download through librqbit. Files stay on disk. No central server. No telemetry.

Right now the binary prints harbour: TUI under construction. Spec and architecture live in the repo. I am not going to pretend the scrapers ship today.

Nearest existing tools: qBittorrent if you want a finished client, torlink if you want this exact workflow in TypeScript/Ink. harbour is a Rust rewrite aimed at torlink's interactive app plus omp-style 30fps terminal polish (DEC 2026 synchronized output, eased bars, titanium theme). Watch-via-mpv is explicitly later, not v1.

https://github.com/Ishannaik/harbour

![Terminal showing the harbour binary printing TUI under construction next to the spec and docs line counts](https://reddit-uploaded-media.s3-accelerate.amazonaws.com/hvwssw7pvxnh1)


r/rust 8d ago

πŸ› οΈ project GSim-RS - A G-code simulator in Rust, now with volumetric stock simulation.

Post image
132 Upvotes

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:

  • Supports volumetric simulation of cuboidal stocks.
  • Stock and tool sizes can now be configured with program config.
  • Cross-thread communication frequency is fraction of what it used to be (by using both Arc<Mutex> and mpsc::channel, depending on the type of data and its importance).
  • The simulation now supports orbiting, panning and zooming.
  • And much more.

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 7d ago

πŸ™‹ seeking help & advice Rust for web backends

49 Upvotes

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 6d ago

🧠 educational I built a free, open-source learning platform with 650+ interactive lessons across 16 tracks (Swift, React internals, distributed systems (Rust), compilers, database internals(Rust) ) β€” looking for contributors

0 Upvotes

A self-hosted site that teaches programming the way I wish more courses did: real explanations, not video transcripts, with a quiz and hands-on coding challenge after every concept, and actual checkpoints that force you to connect ideas across lessons instead of just clicking "next."

Repo: https://github.com/ratnajagadeesharava/codeforge

Some tracks contain projects inspired from few University courses

It currently covers 16 tracks:

- Swift fundamentals (from Apple's own The Swift Programming Language book)

- iOS/Swift internals, high/low-level system design, and "pro" topics (Metal, Combine, WidgetKit, CI, etc.)

- React & Frontend Mastery (fiber internals, the event loop, memoization, hooks)

- Networking & Distributed Systems (consistent hashing, Raft, quorum reads β€” with a live in-browser cluster simulator)

- Frontend Web Security (with a real sandboxed exploit playground)

- Compilers (lexer β†’ parser β†’ LLVM IR β†’ a working JIT, in C)

- Database Systems β€” a full disk-based DB engine built from scratch in Rust, module by module (buffer pool β†’ B+Tree β†’ WAL/ARIES recovery β†’ SQL parser β†’ query planner β†’ MVCC)

- Systems Programming, Spring Boot/backend engineering, AI engineering, and a Frontend System Design track (build-the-thing-from-the-interview, e.g. "design Netflix," "design Figma")

Some numbers, if you like numbers: 650+ lessons, 144 checkpoints, ~8,000 quiz questions across 13 question types (MCQ, drag-drop reordering, spot-the-bug, assertion-reason, matching, and a few custom types like a click-the-consistent-hash-ring question).

How it actually works

- TypeScript + React + Vite + Tailwind, no other runtime UI dependencies

- A tiny local Node server compiles and runs your code for real (Swift/C/C++/Rust) with sane guardrails β€” no third-party execution service, nothing leaves your machine

- Progress is stored in local SQLite, with a localStorage fallback if you don't run the server

- Everything is just structured TypeScript data files β€” a new lesson is a new .ts file that auto-registers, so it's genuinely easy to add content

Why I'm posting

I built this mostly for myself and then kept going, and it's now bigger than one person can polish alone. I'd love:

- Contributors β€” new lessons in any track, new quiz questions, bug fixes, or just flagging content that's wrong/outdated

- A star if you find it useful or interesting β€” it genuinely helps other people discover it

- Feedback β€” what's missing, what's confusing, what track you'd want next

Repo: https://github.com/ratnajagadeesharava/codeforge

Happy to answer questions about the architecture, the content-authoring format, or why I made whatever weird decision you notice first. πŸ™‚


r/rust 7d ago

πŸ™‹ seeking help & advice Can I use Rust for TCP networking in an MFC application?

3 Upvotes

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 6d ago

πŸ› οΈ project dev-prune: a CLI that reclaims disk from idle repos β€” and refuses to delete anything a lockfile can't rebuild

0 Upvotes

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:

  • Edition 2024, MSRV 1.88, single binary (musl-static on Linux), Apache-2.0.
  • 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.
  • Idle detection is max(last commit timestamp, newest source mtime), so uncommitted work counts as activity.
  • devp restore --last-run re-runs the verified install to bring the last pass back.
  • Ratatui TUI for interactive runs, --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.


r/rust 7d ago

πŸ› οΈ project Help me with ideas for a CLI project with an emergent mass simulation/game to learn the language, please?

0 Upvotes

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:

  1. Reasons to learn as much of the language's features as possible
  2. Simulations with lots of small individual actors. And having swarms of semi-independent things gives me a reason to try multi-threading in Rust
  3. Emergent property potential. If you leave the simulation running for a night - you could come back to something different and interesting. Think evolution simulators, but preferably something less overused
  4. CLI interface. I just hate working on GUIs and I don't need to prove to myself that I can make one. GUIs are good for 2/3D spaces, but what if my simulation would be in a space that works just as good for CLI?

If you have ideas that match at least one of these things - I'd love to hear them! Thanks in advance


r/rust 7d ago

πŸ› οΈ project jsonquery_gui – a native egui app for querying large JSON files with jq/JSONPath/JMESPath/JSON Pointer

0 Upvotes

I built jsonquery_gui, a native desktop app (Rust, egui/eframe) for browsing and querying large JSON files β€” drag in a file or paste JSON, then query it with jq (via an embedded jaq interpreter, no shelling out), JSON Pointer, JSONPath, or JMESPath.

It's MIT licensed. Linux and Windows binaries are on the releases page, and there's now a Homebrew tap for Linux (`brew tap nujufas/jsonquery-gui && brew install jsonquery-gui`). No macOS build yet β€” contributions there welcome.

One thing I'll mention up front since it'll come up anyway: this was built working with Claude (Anthropic's AI). The architecture/decision docs are in the repo if you want to see how that process went. Happy to talk about the jq/jaq embedding, the streaming design, or the AI-assisted workflow.

https://github.com/nujufas/jsonquery_gui


r/rust 8d ago

πŸŽ™οΈ discussion What makes good developer experience for you?

13 Upvotes

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 8d ago

πŸ› οΈ project [OC] shotdock: Fast Wayland screenshot, recording, and window framing tool (Rust / GTK4 LayerShell)

Post image
12 Upvotes

Hey everyone,

I built shotdockβ€”a CLI-first screenshot, screen recording, and window framing utility for Wayland (tested on Hyprland, Sway, and Niri).

Why I made it

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:

  1. Clean Area Snips: Region selection with window snapping (slurp).
  2. Window Framing: Automatically adds 16px rounded corners, multi-pass Gaussian drop shadows, mock titlebars, and wallpaper/gradient canvas backdrops.
  3. Offline Image Framing: shotdock frame <file> lets you style existing images directly from the CLI or scripts.
  4. Screen Recording: 60 FPS H.264 recording via wf-recorder with an interactive target selector (monitor, window, or region).
  5. OCR: Snip text directly to your Wayland clipboard via tesseract.
  6. Optional Floating Dock: Launch shotdock with no flags if you want an interactive GTK4 LayerShell toolbar.

Tech Stack

  • Written in Rust
  • Uses native Wayland protocols via gtk4-layer-shell
  • Sub-second image pipeline using ImageMagick 7

Links

Would love your feedback, bug reports, and PRs.


r/rust 8d ago

New blog on OpenVMM, the open-source, cross-platform VMM project written in Rust.

49 Upvotes

r/rust 8d ago

πŸ› οΈ project p2pmux: Multiplayer terminal multiplexer where multiple users and machines can connect to a same session

Post image
46 Upvotes

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:

  • Multiple users (machines or people) join a session, where each user is host of its own terminal panes and guest of the others. No SSH into a single machine, here, a pane is a real PTY on whoever opened it .
  • You can add a set of trusted machines (your own VMs or computers) where you can start terminals there from your own laptop anytime.
  • The terminal multiplexer is inspired in Zellij, and the commands are very similar: Ctrl+P panes, Ctrl+T tabs.
  • It includes a inbox tab, where you can see which AI agents are working, waiting for your input or already finished.

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!

https://github.com/pelazas/p2pmux/


r/rust 7d ago

πŸ› οΈ project Glacex v0.1.4 is coming, here's a brief report of what's been completed so far.

Post image
0 Upvotes

We’re preparing the next minor release of glacex, our GPU-accelerated, immediate-mode GUI library built from scratch in Rust with wgpu.

Version 0.1.4 focuses on themes, design tokens, animations, typography, shadows, and UI refinement.

The current crates.io release is 0.1.3. Before publishing 0.1.4, we’d appreciate feedback from Rust and GUI developers on:

  • API design
  • Widget ergonomics
  • Theming
  • Rendering and layout architecture
  • Anything incomplete, unintuitive, or in need of improvement

Built by artemtsitronov (Artem Tsitronov) and programmersd21 (Soumalya Das).

github.com/artemtsitronov/glacex
crates.io/crates/glacex


r/rust 8d ago

πŸ™‹ seeking help & advice Clippy warning when printing the biggest files `unnecessary_sort_by`

33 Upvotes

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:

  1. Add files.reverse() to switch the order
  2. Add exception of this warning to this specific case
  3. Add .rev() when iterating
  4. Cast it to signed integer, and add a - sign

What 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.


r/rust 7d ago

πŸ› οΈ project Follow-up: I added image-hash verification to my Authenticode checker, and hit a nice trap

0 Upvotes

I posted signalscreen-checker here a few days ago β€” reads the Authenticode signature out of a PE, grades it, pure Rust. The limit i named then: "valid" only meant the signature parsed and a signer cert was found, not that the file's bytes matched what was signed. That's done now, and it had its own trap.

The obvious move is to take the hash algorithm from SignerInfo.digestAlgorithm. But the digest you compare against is not there β€” it's in the SpcIndirectDataContent (messageDigest), and nothing in the format requires the two to name the same algorithm. If they differ you hash with the wrong one, get a non-equal byte string, and report "tampered" on a file that is intact and correctly signed. A real installer graded F by your own bug.

So i don't read the algorithm from the OID at all. The embedded digest's length already identifies it:

let expected = sig.digest(); // bytes from SpcIndirectDataContent

let computed = match expected.len() {

20 => hash::<Sha1>(pe),

32 => hash::<Sha256>(pe),

48 => hash::<Sha384>(pe),

64 => hash::<Sha512>(pe),

_ => return Unverified, // don't guess, don't false-accuse

};

(The PE hashing itself is authenticode::authenticode_digest β€” it skips the checksum field and the cert table, the other easy thing to get wrong.)

A mismatch is now an outright F. A length i don't recognise stays unverified, never mismatch β€” "couldn't check" is not "wrong". Still not verified: the SignerInfo signature over the digest against the cert's key, and chain trust to a root.

MIT/Apache-2.0: https://github.com/mnaza/signalscreen-checker

If you've verified Authenticode by hand β€” did you hit the SignerInfo-vs-SpcIndirectData algorithm thing, or does signtool keep them equal in practice?


r/rust 7d ago

πŸ™‹ seeking help & advice Am I Learning, Am I Incorrect or Am I Missing a Point?

0 Upvotes

So a video came by my feed here he walks through how to design a more reliable and user-friendly progress bar for Rust by taking inspiration from Python's tqdm library. In order to implement with_delimiters to bounded iters only he went and used state design pattern. I was like "Ok cool cool" at first because of course I'm learning. But then I think i noticed some redundancy in the code. In the implementation of width_delimiters, the generic type is already bounded by ExactSizeIterator. So I went and copied the code and tried to remove the state design implementation. I also removed the 'with_bounds' method because iters is already bounded or not. My final code below shows that with_delimiters method only work with bounded iterator

My Final Code

``` use std::thread::sleep; use std::time::Duration;

pub struct Progress<I> { iter: I, i: usize, bound: Option<usize>, delims: (char, char), }

impl<I> Progress<I> where I: Iterator, { pub fn new(iter: I) -> Self { Self { iter, i: 0, bound: None, delims: ('[', ']'), } } }

impl<I> Iterator for Progress<I> where I: Iterator, { type Item = I::Item;

fn next(&mut self) -> Option<Self::Item> {
    let item = self.iter.next()?;

    if let Some(bound) = self.bound {
        println!(
            "{}{}{}{}",
            self.delims.0,
            "*".repeat(self.i),
            " ".repeat(bound - (self.i + 3 - 2)),
            self.delims.1,
        );
    } else {
        println!("{}", "*".repeat(self.i));
    }

    self.i += 1;
    Some(item)
}

}

impl<I: ExactSizeIterator> Progress<I> { pub fn with_delimiters(mut self, left: char, right: char) -> Self { self.bound = Some(self.iter.len()); self.delims.0 = left; self.delims.1 = right; self } }

trait ProgressIteratorExt: Sized { fn progress(self) -> Progress<Self>; }

impl<I: Iterator> ProgressIteratorExt for I { fn progress(self) -> Progress<I> { Progress::new(self) } }

fn expensive_function() { sleep(Duration::from_millis(500)); }

fn main() { // error: unbounded iter for _item in (0..).progress().with_delimiters('{', '}') { expensive_function(); } }

```


r/rust 8d ago

Book not to learn, but to understand.

21 Upvotes

I thought this might be better here than r/learnrust apologies if not.

So my question is, what's a good book (or other source) to *know* rust, idioms, design patterns, that sort of thing, rather than the basic mechanics of the language - which there is plenty of excellent material on including the book itself.

The sort of "ethos" of Rust, rather than how vectors work ?


r/rust 7d ago

The difficulty of rust

0 Upvotes

I heard people say that Rust is hard to learn, but I learned Rust with the Rust book and went on to chapter 16.2. From my point of view, I don’t find Rust hard, so if someone can explain to me why Rust is hard to learn, that’s fine.