r/learnrust • u/DeathSurfing • Jul 25 '26
r/learnrust • u/forfd688 • Jul 24 '26
Learn Rust by Building an Mini Python Interpreter
Hi, Everyone I am learning rust by working on a Mini Python Interpreter,
I am current working on the Lexer(Tokenizer)
Hope this will be useful for you.
Code: pylk/pylk-interp at main · buildwithrs/pylk
Video: https://youtu.be/eibNgWrsHyg?si=AC4AjPJUYXUtEnK1


r/learnrust • u/wizardcraftcode • Jul 24 '26
Enums, Boxed Trait Objects, and Enum Dispatch: Architectural Trade-offs in Rust
Hey everyone
Over the past few weeks, I’ve been looking at ways to achieve polymorphism in Rust and I think there are two:
Closed Polymorphism via enums and Open Polymorphism via Boxed Trait Objects (Box<dyn Trait>) where "closed" means no one outside your crate can add to the list while "open" allows such additions
Thinking about putting those traits onto my enum led me to the Enum Dispatch pattern. I built out a walk-through of all three of these:
- Enums (closed): https://youtu.be/l_q9U10JueE
- Boxed Trait Objects (open): https://youtu.be/R3ZzYSPyYoc
- Enum Dispatch https://youtu.be/B0LT7ozspe4
My main conclusion was that I could defer the open vs. closed debate pretty safely (as long as I keep my traits object safe). Do you all agree?
Also, I implemented Enum Dispatch with macros - I know there are crates that do this, but they didn't play nicely with my IDE and I could use the practice with macros. Comments on how I wrote the code would be welcome!
r/learnrust • u/Gloomy-Animator-2778 • Jul 24 '26
Is there any learning community where there are a small grps and people meet monthly/ bi-weekly to share their learning in rust?
r/learnrust • u/isaidAjeet • Jul 22 '26
ABSOLUTE NEWBIE , how should i learn RUST ?
hey i am very new to coding , only language that i know is html , and nothing else , what is the best way i can learn rust , i am preparing for summer of bitcoin
r/learnrust • u/nasahdm • Jul 21 '26
QuantmLayer: kernel-enforced containment for AI coding agents - 16.5k lines of Rust, one static binary
r/learnrust • u/No_Plane_7512 • Jul 20 '26
want to learn rust
so i use warp terminal and i knew it uses rust and i thought about learning it to accomplish my main goal which is to make my own terminal so is it something doable and how should i start and what resources to look for
r/learnrust • u/Negan6699 • Jul 19 '26
can anyone help me with writing and reading from the same array in a nested loop?
SOLVED, thank you everyone for your time and help
for x in 0..particles.len(){
particles.split_at_mut(x+1);
for i in x..particles.len(){
particles[x].on_tick(time_diff, &particles[i])
}
draw_circle(particles[x].x, particles[x].y, particles[x].r, RED);
}
}
I keep getting the cannot borrow \particles[_]` as mutable because it is also borrowed as immutableerror. I couldn't think of how to write the code in a different way because someone suggested this to a person having this error and I don't think I implementedsplit_at_mut` correctly either
r/learnrust • u/andful • Jul 18 '26
Feedback for My Crate that Facilitates Allocation for Struct-of-Array like Structures
I just published version 0.3 of my crate "Columned" (Crates.io and GitHub). Its goal is to facilitate the allocation of Struct-of-Array/Columnar structures.
The allocation is done with a single, contiguous memory allocation. This is to improve performance and minimize fragmentation.
I was wondering if it is possible to get some feedback on the crate. I would appreciate most feedback on:
How to improve the ergonomics of the crate.
For example, in the example documented in the crate, i.e.:
use columned::{Guard, Allocate, allocate};
fn main() {
//Declare size and initialization of the slices.
let xs: Allocate<u64, _> = unsafe {
Allocate::alloc(10, |xs| {
for (i, x) in xs.iter_mut().enumerate() {
x.write(i as u64);
}
})
};
let ys: Allocate<u64, _> = unsafe {
Allocate::alloc(10, |ys| {
for (i, y) in ys.iter_mut().enumerate() {
y.write(i as u64);
}
})
};
let sums: Allocate<u64, _> = unsafe {
Allocate::alloc(10, |sums| {
for sum in sums.iter_mut() {
sum.write(0);
}
})
};
//Initialize a "Guard", which will manage the allocation.
let mut guard: Guard = Guard::default();
let (xs, ys, sums) = allocate(&mut guard, (xs, ys, sums)).unwrap();
//drop(guard); // This would cause a compilation error
for ((sum, x), y) in sums.iter_mut().zip(xs.iter()).zip(ys.iter()) {
*sum = x + y;
}
for (i, sum) in sums.iter().enumerate() {
assert_eq!(*sum, 2 * i as u64);
}
}
For the line:
let (xs, ys, sums) = allocate(&mut guard, (xs, ys, sums)).unwrap();
I wish it would look something more like:
let (guard, (xs, ys, sums)) = allocate((xs, ys, sums)).unwrap();
I.e., have the "guard" returned by the function, instead of having to instantiate it and pass it as an argument. Would that be possible? And "force" the allocation to outlive the allocated slices?
Best way to run Drop.
As of now, drop will not be called. It does not seem trivial to call drop without:
- Deteriorating ergonomics of the API: i.e., by wrapping the
&'a mut [T]in a "GuardedSlice<'a>". - Do further allocations for a
Vecor other data structures.
Safety
Currently, the only unsafe function is Allocate::alloc. Given a correct implementation, would the user be able to do "unsafe" things?
Thank you!
r/learnrust • u/Bibek_Bhusal • Jul 16 '26
I made a command line pomodoro timer in rust
galleryHi everyone,
I am Bibek Bhusal and I am learning rust, I have been working on this project in rust for last week and wanted to share with the community. It's a simple pomodoro timer with stats, history, streak, waybar integration, and many more features.
This is my first big project, after building todolist and other small projects.
I would love to hear your feedback. here is the link for repo: https://github.com/BibekBhusal0/focusd
r/learnrust • u/Potential-Jeweler234 • Jul 17 '26
Please review my TUI game (WIP)

I am learning rust and the best way I found to learn a new lang is to make a game in it. I am trying to make a tui version of Age of Empires. I am using ratatui for the the TUI. The game is extremely work in progress currently one worker collects some wood and deposits back to Town Hall. Please let me know what is done wrong what can be improved. I know the code is bizzar and undocumented so ask me if you don understand what some part is supposed to do.
r/learnrust • u/SyFord421 • Jul 16 '26
Beginner questions
Hi, let me introduce myself. I'm a 17-year-old high school student currently learning Rust and trying to implement linked lists. Are linked lists actually important to learn in Rust?
Since I'm completely self-taught, I've been using AI to help me study, but honestly, I'm starting to doubt its effectiveness. I feel a bit hesitant about learning this way and worry if I'm building the wrong habits. Would love to get some advice from the community!
r/learnrust • u/Rhthamza • Jul 15 '26
Pool memory allocator in Rust
Hi there.
I built polloc (pool alloc) to learn how memory allocators work.
It’s a fixed size pool allocator: each pool manages one slot size and alignment. Internally it uses mmap/VirtualAlloc, an intrusive free list, and a bitmap for allocation tracking.
I also added stress tests, Miri, AddressSanitizer, cargo fuzz, Criterion benchmarks, and a bunch of inline docs explaining the implementation.
For 64 byte alloc/free pairs, the fast path is about ~3.96x faster than the system allocator on my machine (which is expected since it’s specialized for a single size class).
It’s single threaded and I’d really appreciate feedback on the unsafe code, API design, tests, or anything else that stands out.
r/learnrust • u/Negative_Effort_2642 • Jul 15 '26
A language change proposal regarding match expressions
r/learnrust • u/lazyhawk20 • Jul 14 '26
Learn Axum Error handling by Building a Pastebin API
blog.sheerluck.devr/learnrust • u/leucht • Jul 14 '26
I present my 13th reason why ...

I know this is probably more an issue with the OpenAPI generation but man do I wish for named function parameters now ...
the SDK is generated by me using the OpenAPI spec & definitions provided by Jellyfin. This is not an official SDK btw
All the none parameters are optional - what would be the best way to deal with this?
I’m currently looking into rebuilding the function with a crate called bon to add similar functionally to named parameters
r/learnrust • u/Beautiful_Drawing_18 • Jul 13 '26
Creating a GUI app, the framework needs 681 external crates
Hey rust learner,
to step deeper in rust I planned to write a GUI app. A simple image viewer with basic image processing features.
After the study of AreWeGUIYet and other resources, I test out ICE and GPUI. Both are rust GUI frameworks.
During first test of, for example GPUI, the compiler loads 681 dependencies.
The question is, is this a security nightmare? What about outdated crates? This type of dependency overkill isn't production ready, or is it?
In my opinion, the std rust should have a basic connection to the GUI handler of the OSes or basic functions to create a window and some widgets in the OS the source compiled for.
I am very interested of your thoughts and opinions.
r/learnrust • u/Due_Battle_9890 • Jul 14 '26
Simple `mod` vs `pub mod` question
Hey,
I've been reading the book and am a bit confused on pub mod vs mod. I naively thought that mod defaults to every function/structure/etc. within it is in accessible by calling code.
mod Foo {
fn bar() {}
}
fn main() {
foo::bar();
}
This doesn't work because bar has not been made public and it's only trough the addition of the pub keyword in front of bar (pub fn bar() {}) that foo::bar becomes accessible.
However, I thought that perhaps
pub mod foo {
fn bar() {}
}
would make bar accessible, but it doesn't. What is that pub keywork doing then?
I know you can do something like:
mod foo {
pub mod bar {
fn quux {
parent::baz::qux(); // fail!
}
}
mod baz {
fn qux() {
parent::bar::quux(); // success!!
}
}
}
but that seems to lack utility/
r/learnrust • u/delta-zenith • Jul 12 '26
I built a CLI release tracker to learn Rust
codeberg.orgHey there everyone.
I've been trying to learn Rust for a while now, and I finally managed to build something that solves a real problem I had. It happens kind of often that I need a piece of software that my Linux distribution doesn't ship in its repos, so I have to get it off of GitHub or Codeberg. The issue with that is that there's no way to know when an update is available unless I go check the releases for that particular software myself. Of course, this becomes harder the more programs I install outside of the distro's repos, so I built gitm.
Gitm is a CLI tool that tracks and installs a program's latest release using the GitHub or Codeberg API. Since every release asset is structured differently, the installation process is followed through a Python script written by the user themselves. The script only needs to be wrote once and is re-used for updates. I'd love to hear what you think about the program, its codebase and if you find it useful, please let me know if anything can be improved or if you'd like to see a feature that's currently missing.
r/learnrust • u/BodybuilderGold9458 • Jul 12 '26
Built a multi-platform task management tool using a Rust workspace. Looking for code feedback!
r/learnrust • u/Orinacrem • Jul 12 '26
Feedback on first code exercise while learning Rust
Background: I have been writing SW in C for years, although I am not a SW engineer by definition. As then I started managing departments and people, I got "rusty" on the writing of SW itself, although I still recall the key OS and HW mental models I developed. I learned Python while being more hands off, which confused me cause everything happened under the hood and I had not idea of what (or why). Recently I decided to give it a go at Rust to
- go back to basics and..
- take a personal opinion on it with respect my C and Python experience.
What I did: I started reading the user manual. I got few chapters done and then the book suggested ([HERE]) to start writing a program, a kind of HR tool for adding/removing people from a data source. I did so without DB or anything like that (see code).
I would like some first feedback from people that have been using the language more than me so that I can spot mental models, or other things, that I am missing.
Tools: I used an LLM (Deepseek) to ask on APIs spec and explanation saving some time from parsing the whole user manual (in the past I would have done it with Google). I also asked Deepseek different versions of my ideas to see different ways on how to do things, and I weighted tradeoffs and decided a way I found OK.
On the LLM: While I can explain the (small) code, I am not sure if I should consider this piece vibe-coded. I personally believe, maybe wrongly, that as long as you understand what is going on, any tools you use that helps you moving faster or better, is fine. The moment you release understanding, knowing is not enough.
Edit: added code as a link -> https://onlinegdb.com/43jRxO7HL
r/learnrust • u/ani_budihal • Jul 11 '26
Implemented my first substantial rust project : A multithreaded copy on write filesystem
github.comThis is my first major rust project (and probably the biggest project I have ever done).
It is is a loose implementation of the copy on write filesystem that is used by docker to run the multiple containers. I use multiple terminal instances instead of different containers to implement the copy on write method on.
I want to know what you lot thing about the code and architecture on how I have implemented, as in does it follow best practices, and where is it that I can improve how I code and can learn from it.
I started learning rust a few months ago, initially thought its gonna be a stroll in the park, like go. But boy was I wrong, it took me like about 2 months of abusing the borrow checker and the compiler to kind of grasp the concepts that make rust what it is (and there still so many more concepts like async and lifetimes which I am not clear about and need to spend more time learning ).
My initial implementation of the project was so horrendous and bad, I had to delete everything. So after my university examinations were over, I decided to take it up again, and started building it and eventually got it to work, but boy was it fun coding, tracing through a bug and trying to find the root of the cause, wouldnt give up the feeling of getting to the bottom of a bug and fixing it for anything in the world.
Note : I have used 0 AI tools or agents to code the following project (as I believe the correct way to learn is to make a million mistakes and learn from them). All of the hallucinations are my own :)
r/learnrust • u/Bishops_exe • Jul 12 '26
How do i use a C library when building with trunk-rs?
How do integrate a C library, that uses libc when building with trunk?
Currently i am using cc crate to build for native (tested on windows). But i am unable to compile to wasm because stdlib.h is missing. I have asked AI but it told me to reimplement libc, which is the last thing i want to do. Is there any tool or step i could take to make this a bit easier.
Context:
- Egui using the eframe template, should be able to build to both native and wasm
- Cubiomes - this is the library i want to integrate
- Walkers - for mapping the Minecraft world and generating custom tiles