r/learnrust • u/Aghasty_GD • 1h ago
r/learnrust • u/SirKastic23 • 1d ago
Learning Resources for Complete Beginners?
Hi everyone, I've been using Rust for the past 5 years now. I really enjoy the language, but when I started learning it I already had a huge baggage of knowledge from other programming languages I had studied prior
What I want to know is if anyone is aware of any resources (good or bad) that tries to teach programming with Rust for someone who's new to programming and computers
The book is a good resource, but it assumes previous experience and would be hard for a newbie to learn and understand all
I'm aware Rust is more complex, and that teaching it to a beginner would be harder than teaching Python. But still I'm looking for resources that at least try
I'm really surprised that I haven't found any yet, so I'm asking here. Thanks for your attention
r/learnrust • u/lazyhawk20 • 1d ago
Rust Control Flow in Practice - Build a Number Guessing Game
blog.sheerluck.devr/learnrust • u/iluxav • 1d ago
ply: A daemonless container runtime and package manager written in Rust
r/learnrust • u/franwbu • 1d ago
Throttle: an open-source per-process bandwidth limiter for Windows in Rust (egui + WinDivert)
r/learnrust • u/ScoreSilver9140 • 1d ago
Beginner looking for a project to actually learn Rust
r/learnrust • u/luminade-studios • 1d ago
Routing a URI value to Score - Rust + Axum - JS - 02
youtube.comr/learnrust • u/Sofiabelen15 • 3d ago
Visualizing Rust's Vtables: How dyn Trait Works In Memory (Comparison to C++ CRTP & virtual functions)
sofiabelen.github.ioI’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 :)
r/learnrust • u/Klutzy_Bird_7802 • 2d ago
Glacex v0.1.4 is coming, here's a brief report of what's been completed so far.
r/learnrust • u/Aromatic-Theme7633 • 2d ago
Can I use Rust for TCP networking in an MFC application?
r/learnrust • u/AmonAquila • 2d ago
Overflow
Overflow is when an arithmetic exceeds the maximum value an integer can hold.
let mut x: u8=256
Support your answer if overflow is likely to occur on the variable x. If so, list 3 ways we can handle the situation. 🧠👀
r/learnrust • u/luminade-studios • 5d ago
First time here but I am building a minimal web game in Rust and Axum with no Javascript
I am trying to build a game in Rust just using Axum, HTML, and CSS, and trying to avoid using Javascript and I am documenting my progress in my youtube channel here: https://www.youtube.com/watch?v=ftYwc2NlqMI
r/learnrust • u/Otherwise-Western991 • 5d ago
stale: An open-source, fail-closed DeFi security guardrail suite in pure Rust for autonomous AI agents
Hey everyone,
With the rapid rise of autonomous AI trading agents (interacting with Uniswap, cross-chain bridges, and lending protocols), there is a critical vulnerability that many agent frameworks ignore: pre-flight oracle and network integrity.
If an agent queries an RPC for an oracle price, and that RPC returns stale data due to network congestion, or if an L2 sequencer just rebooted and transactions are about to get MEV-sandwiched, most agent runtimes blindly execute and lose capital.
We built stale, a lightweight, pure Rust pre flight security guardrail library:
- GitHub: https://github.com/Ramprasad4121/stale
- Crates.io: https://crates.io/crates/stale
Core Architecture & Invariants
- Strictly Fail-Closed: Many Web3 libraries fail open (e.g., returning
Okor default values if an RPC returns a 500 error). Instale, any failure mode RPC timeouts, malformed ABI data, non-ASCII hex strings, or underflowing timestamps strictly returnsBLOCK. - Zero Runtime Panics: We eliminated all
unwrap()andexpect()calls across the runtime library. All arithmetic on token reserves and timestamps uses checked math, saturating math, or quotient-remainder decomposition to preserve precision on small amounts. - What It Guards:
- Chainlink Data Feeds: Staleness checks against configurable
maxAgeand multi-feed deviation detection. - L2 Sequencer Liveness: Direct querying of official Sequencer Uptime feeds (Arbitrum, Optimism, Base, Scroll, Mantle, Metis, zkSync) with automatic enforcement of the 3600-second restart grace period.
- DEX Pool Depth: On-chain liquidity verification for Uniswap V2 and V3 pools before routing a swap.
- EIP-7702 Phishing Guard: Inspects bytecode headers to prevent agents from sending approvals to delegated EOAs masquerading as immutable contracts.
- OFAC Compliance: Direct on-chain verification against the Chainalysis Sanctions Oracle.
- Model Context Protocol (MCP) & CLI: In addition to the Rust crate (
cargo add stale), it includes a native CLI and an MCP server (stale-mcp) so LLM agent frameworks (like Claude Desktop or local agents) can use these checks as native tools.
Would love feedback, edge-case suggestions, and contributions
r/learnrust • u/SquareShort9309 • 5d ago
Best template for fast I/O in Competitive Programming ?
I'm thinking of doing competitive programming in rust and came up with this template :
Example problem : https://www.codechef.com/practice/course/logical-problems/DIFF800/problems/AVGPROBLEM
use std::io::{Read, Write, BufWriter, stdin, stdout};
fn main() {
let mut input = String::new();
stdin().read_to_string(&mut input).unwrap();
let mut data = input.split_whitespace();
let mut output = BufWriter::new(stdout().lock());
let tests : u16 = data.next().unwrap().parse().unwrap();
for _ in 0..tests {
let a : f32 = data.next().unwrap().parse().unwrap();
let b : f32 = data.next().unwrap().parse().unwrap();
let c : f32 = data.next().unwrap().parse().unwrap();
let avg = (a+b)/2.0_f32;
if avg > c {
write!(&mut output, "YES\n").unwrap();
} else {
write!(&mut output, "NO\n").unwrap();
}
}
}
Is this template good ? or Is there a better way to do it ?
r/learnrust • u/Developer5702 • 6d ago
Review this pure backend project
I’m thinking of creating a complete authentication service provider backend in Rust, which would include - OTP, magic links, email-password, SSO and a lot more.
Basically something like AuthJS or Appwrite (only the authentication service of theirs), with proper failure handling, spike handling, backpressure and everything that such a system requires at scale.
This would help me learn async Rust in detail (I’ve never done it) and system design for such a system.
This is not a new idea, but I don’t mind if it teaches me stuff.
Review this project idea.
Open to feedbacks/roasts.
r/learnrust • u/FranzHenry • 6d ago
Good architecture for Rust as backend (tauri 2)
TL;DR: What would be a good architecture for a Rust backend in the Tauri 2 framework with 3 user-facing interfaces (GUI, MCP, CLI) and multiple external resources (Docker, Git, SQLite, file system, remote data storage, ...) that does almost everything concurrently with tokio?
Hi. I'm currently building a tool that aims to help Business Central (BC - ERP system by Microsoft) developers and vibe coders operate more efficiently. The tool will make managing Docker containers, repositories, dependencies, and so on way easier. In addition to the GUI (Vue/Vite/Element Plus), I also want to provide a CLI and MCP. To make it even easier for the user, I plan on implementing a project-based system where you can set everything up for a customer, and if something changes (e.g. the BC version), the user updates the config and the program takes care of the rest.
Obviously, there are quite a few interfaces I need to cater to. For one, there are three different front-facing ones. And then, on the backend, there is Docker (bollard), Git (git2), SQLite (Tauri SQL plugin), the file system, remote resources, and so much more. Of course, all of that is built for concurrency.
I am in the very early stages of development and have implemented the basis for the Docker capabilities (backend and GUI) and started on Git. Of course, this already involves a lot of file system and remote resource (http, downloads, ...) interaction. I have yet to begin with any of the SQL, CLI, or MCP stuff. But I already notice some challenges and therefore want to apply a design pattern that allows me to implement all of these features without it becoming a complete clusterduck.
I tried Hexagonal Architecture from Alistair Cockburn in a Python project once and could imagine that it fits Rust as a language quite well. On the other hand, while thinking about implementing it, I already encountered heaps of challenges (which does not mean that this can't be the answer).
One thing I want to mention is that I do not have a lot of experience with Rust. I read the book a second time, more focused this time, over the last two months or so, and this project started as a practice project while I was in the middle of the book. Since I primarily focus on learning Rust right now, I did not dive all that deeply into the tauri framework itself, which I will definitely do soon.
But until then: What would be a good architecture to implement before moving on with new features? If you have the time I would be glad to read about your reasons and maybe even experience with it.
r/learnrust • u/conceptcreatormiui • 6d ago
Am I Learning, Am I Incorrect or Am I Missing a Point?
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/learnrust • u/Interesting_Home_114 • 7d ago
How to convert a &mut i32 to integer?
Hello everyone. I am following the rust programming language book and I've just now finished chapter 8. Just doing some of the exercises suggested at the end.
I have written this simple function to find the mode from a given list of numbers:
fn mode(list: &mut Vec<i32>){
let mut items=HashMap::new();
for i in list{
let count = items.entry(i).or_insert(0);
*count += 1;
}
let mut largest_value = -5; // initialize to a very small number
let mut most_frequent_key = 0;
for (key, value) in items{
if value > largest_value{
largest_value = value;
most_frequent_key = key;
}
}
println!("mode: {most_frequent_key}");
println!("{:#?}",items);
}
In the last step of the second for loop, I want the most_frequent_key variable to accept my key variable but I understand that the former is expecting an integer and key is a mutable reference to an i32 value. So I don't know what to do here.
Previously, through some trial and error I did figure out that I could use the dereferencing(*) operator on key to accomplish that but then the compiler tells me that I am apparently "moving" the items value and hence can't use use it again in the println!() statement in the last step of the function.
r/learnrust • u/lazyhawk20 • 7d ago
Build a Scientific Calculator in Rust - Understanding Variables and Types
blog.sheerluck.devr/learnrust • u/ziggerslayer • 8d ago
what i’ve learned so far
wrote my first article on X detailing about little things I learned apart from the Rust book’s content while reading through chapters 1-3 this past week.
you can find it here: https://x.com/zepredos/status/2094169365424013351?s=20
i’d appreciate any feedback you have and would love to learn more Rust!!
r/learnrust • u/MostafaSensei106 • 9d ago
I built a local vector database for Flutter powered by Rust and HNSW graphs (Waffle-DB)
github.comHey everyone,
Most local storage options in Flutter like SQLite or Hive are built for scalar data and fall apart when you need fast vector similarity search for on device AI, semantic search, or high dimensional embeddings
I built waffle_db, an embedded vector database for Flutter and dart apps by Rust. It uses HNSW graphs for approximate nearest neighbours, sledge for persistence, and Rayon for parallel batch ingestion.
How it works under the hood:
Off thread Rust execution: Graph indexing, cosine distance math, and persistence run in Rust via FFI, keeping the Flutter UI thread completely free of jitter.
Native HNSW graphs: Provides k-NN retrieval even across large vector spaces instead of linear brute-force scans.
Memory efficiency: Uses zero-copy typed buffer views (Float32List) across the FFI bridge to minimize heap allocations.
Metadata and Namespaces: Stores arbitrary payload metadata alongside vectors and supports logical collections (WaffleCollection) with automatic ID namespacing.
Prebtuned profiles: Comes with configurations out of the box like mobileProfile (quantization enabled, lightweight graph parameters), serverProfile, readHeavyProfile,writeHeavyProfile
Pub: https://pub.dev/packages/waffle_db
GitHub: https://github.com/MostafaSensei106/Waffle-DB
If you are building local RAG pipelines, on device semantic search, or AI features in Flutter, check it out and let me know your thoughts or feedback.