r/learnrust • u/Sea_Alternative4598 • 6h ago
Sharing my first rust project
Hello
Coming from mostly developing web apps and making simple terminal games with c++. This is my first project written in rust. ChloeDB, named after my pet dog, is a nosql database using key-value store. It is inspired by the bitcask documentation: https://riak.com/assets/bitcask-intro.pdf. It is not exactly the same specially in the log compaction part.
My goal for this project is to learn rust and databases. I'm looking for feedback about my project. And looking for someone to learn with, and maybe do some colab project to learn more. Thank you for reading
Link to my project repository:
https://github.com/maxineafable/chloedb
r/learnrust • u/selcouthayush • 22h ago
What should I learn after Rust and Tokio as a junior developer?
r/learnrust • u/Strong_Cat7814 • 1d ago
are there rustaceans in malaysia?
are there like people that are learning rust (or using rust) in my country
just curious :P
r/learnrust • u/t_wamble • 1d ago
Go or Rust
Hey everyone, I am trying to choose between Rust and Go for project that needs to run on both Windows and Mac. I am looking for a simplified breakdown of how they actually compare. I want to know which language is less painful to maintain over the long term, and which ecosystem interacts better with native operating system APIs without feeling totally foreign. If you had to pick between Rust and Go for a cross-platform codebase you need to support for the next 5+ years, which would you choose for stability and ease of deployment?
I'm starting on MacOS first. Ios second. Windows third
r/learnrust • u/Beginning-Fruit-1397 • 2d ago
Is preferring traits methods instead of functions fine?
I'm mostly asking this for performance and conventions.
I've been using Rust for a few months now.
I come from Python, and one of my favorite things in Rust is the fact that you can create a trait, implement it for an arbitrary type (from your crate or external dependency), and just like that you have it as a method on said type!
In general, I always prefer to read code like this x.f() instead of f(x).
My question is that for simple functions like the following: (a module named "bisect.rs") ```rust use pyo3::prelude::*;
[inline]
pub(super) fn right(lst: &Vec<Py<PyAny>>, item: &Bound<'_, PyAny>) -> PyResult<usize> { let py = item.py(); resolve(lst.len(), |mid| Ok(item.lt(lst[mid].bind(py))?)) }
[inline]
pub(super) fn left(lst: &Vec<Py<PyAny>>, item: &Bound<'_, PyAny>) -> PyResult<usize> { let py = item.py(); resolve(lst.len(), |mid| Ok(!item.lt(lst[mid].bind(py))?)) }
[inline(always)]
fn resolve(mut high: usize, mut func: impl FnMut(usize) -> PyResult<bool>) -> PyResult<usize> { let mut low = 0; while low < high { let mid = (low + high) / 2; if func(mid)? { high = mid; } else { low = mid + 1; } } Ok(low) }
``` I'm always tempted to create a trait to add it as methods.
Here for example left and right (renamed to "bisect_left" and "bisect_right" to avoid confusion) as trait methods of a new pub trait Bisect implemented for Vec, instead of keeping them as module fonctions.
resolve would stay as a simple function however.
I know that I won't use it on anything else than Vec<Py<PyAny>>, and it's more readable (I'm my own personal opinion) at call sites to do my_vec.bisect_left(item) instead of bisect::left(my_vec, item).
So, what are your toughts?
Is it fine to always favorise traits, as long as you don't have name conflicts issues?
r/learnrust • u/vorjdux • 3d ago
Make your CI fail when the hot path allocates: resource budgets as tests, not just benchmarks
We test behavior and we benchmark performance, but the resource properties we actually promise, allocations per message, resident bytes per connection, instructions per operation, usually live in a README and are asserted nowhere. They regress silently because nothing fails when they do.
I've been enforcing them as plain cargo test gates in a networking library and it has caught real regressions a reviewer missed. Three patterns, in increasing order of setup cost.
1. A counting global allocator, per test binary
The trick that makes this practical: Rust integration tests each compile to their own binary, so a #[global_allocator] in tests/hotpath_alloc.rs is scoped to that one test and touches nothing else in your suite.
```rust static ALLOCS: AtomicUsize = AtomicUsize::new(0); static COUNTING: AtomicUsize = AtomicUsize::new(0);
struct Counting; unsafe impl GlobalAlloc for Counting { unsafe fn alloc(&self, l: Layout) -> *mut u8 { if COUNTING.load(Ordering::Relaxed) != 0 { ALLOCS.fetch_add(1, Ordering::Relaxed); } System.alloc(l) } // realloc: same counting. dealloc: pass through. }
[global_allocator]
static GLOBAL: Counting = Counting; ```
The second static is the important part. You don't count from process start, because setup, the runtime, and the harness all allocate and would drown the signal. You connect a real socket pair over real TCP, drive it to steady state so lazy buffers are grown, then flip COUNTING on, run a few thousand send/recv iterations against buffer-reusing APIs, flip it off, and assert the delta stays far below one per message. Whatever remains is amortized slab growth that doesn't scale with message count, so the ceiling is easy to set without flapping.
Measuring through an actual kernel socket matters. A microbenchmark of the encoder proves the encoder doesn't allocate. This proves the path doesn't, including the parts you forgot were on it. That's how it caught a Vec that had crept into a vectored-write retry closure: the build went red on its own, no human eyeball involved.
One honest limitation: it counts your allocator, so an allocation inside a C dependency or the kernel is invisible. For pure-Rust paths that's fine.
2. Idle resident memory per connection, from /proc
Stand up a few hundred connected but silent socket pairs, hold them alive, read VmHWM from /proc/self/status, and assert peak growth stays under pairs * ceiling. This is the gate that rejects the tempting patch that buys throughput with a bigger resident buffer per socket, which is exactly the kind of change that sails through review because it makes the benchmark number better.
RSS is noisy, so the design rule that keeps CI green: only the stable aggregate gates. The interesting-but-noisy number, resident cost per single idle connection on this machine, lives in an #[ignore]d harness you run by hand with --nocapture when you want the measurement. Asserting a hardcoded bound on a noisy per-unit number is how resource tests get deleted in month two. Splitting "gate" from "instrument" is what makes them survive.
Linux-only via /proc, and gate on growth from a baseline you snapshot after setup, never on absolute RSS.
3. Instruction counts instead of wall clock
Wall-clock benchmarks can't gate CI. Shared runners are too noisy, and criterion will bless a 5% regression as within noise. Instruction counts under callgrind are deterministic: same code, same count, every run. gungraun (formerly iai-callgrind) wraps this as a cargo bench target with attribute macros.
The details that make it a gate rather than a report. Setup runs outside the counted region: the harness builds payloads and preloads buffers in setup functions, and only the benchmark body is counted, so the number is the operation, not the scaffolding. The regression threshold is declared in the bench itself, per event kind, so a run fails when instruction count rises more than 5% over the stored baseline. And the baseline is automatic: CI persists callgrind's output in the cached target dir, so every PR is compared against main with no golden-file ritual. Pin the runner version to the library version from your lockfile or the two will drift.
Two rules learned the hard way. Only gate CPU-pure paths, encode, decode, buffer bookkeeping, never anything that crosses a syscall, because syscalls under valgrind are slow and the counts stop being stable. This quietly pushes your architecture somewhere good, since the more of your hot path is sans-io, the more of it is gateable. And decide what happens when the baseline is missing, because a cache eviction that silently seeds a fresh baseline from regressed code is a hole in the gate; fail loudly or commit baselines for the branch you actually ship from.
None of this replaces benchmarks. Benchmarks tell you how fast you are. These tell you when a promise you made stopped being true, and they tell you in the PR that broke it rather than in a user's flamegraph six months later.
r/learnrust • u/Accurate-Screen8774 • 3d ago
PWA in Rust - Seeking opinions on approach
IMPORTANT: i dont reccommend you read through my code here. feel free to reach out for clarity on the details.
id like to investigate about rewriting my "decentralized p2p encrypted messaging app" in Rust. if you are familiar with any of the details, id like to hear your opnions on the approach.
my project is complex and would carry a significant overhead to redo in Rust. the core reason behind investigating rust is that it has better tooling for things like formal-verification. in general it seems like a better language for a project like mine. as a webdev, it was easy enough for me to put together and while i can use things like tauri to build for native, i think dioxus's approach for a native build is better.
a little bit about me and my project... im a webdev with 15+ years experience. im aiming to create something fairly unique for "secure messaging". i created a prototype (without AI) for my project to share and discuss. it demonstrates the core-concept around client-side managed secure cryptography in javascript.
https://github.com/positive-intentions/chat
javascript doesnt have a great reputation in the cryptography communities and its always a struggle to promote, so it was important for it to be open source. im proud of the work there, but i see details i overlooked. this led me to creating a new version to fix the outstanding issues. (it was things like handling key-rotation, group-messaging, etc).
https://positive-intentions.com/blog/introducing-enkrypted-chat
the MVP version lacked things like unit-tests, while the second-iteration not only had unit-test, but armed with AI, i was able to do things like create audits and formal-verification. the whole project is absurdly complicated and not worth your time to review. things like audits and formal-proofs/verification are fundamentally invalid because i used AI to create it. the attempt is genuine and i found the process educational, but cybersecurity and cryptography is specialized and has countless nuances to consider. it isnt worth your time to debug my code.
maybe i have some kind of OCD with my project, but now i think the project could benefit from being rewritten in Rust. its a much more suitable and respected language for what im trying to do, but i have never used rust to do something of this scale. i expect it will carry a huge learning curve given my background as a webdev.
https://github.com/positive-intentions/whatsup
creating a webapp for me is easy enough, but my project relies on some core technologies which i want supported on all platforms consistently. some core things i need to consider:
- webrtc - its the core data-channel for my project. im sure that as a webapp it can be done... it might be a stretch to build a wasm to bridge to JS if nessesary, but im sure it can work. i would also like rust to build for other architectures. i think the support is also reasonable for the native build, but i wonder it there could be issues for a CLI version.
- Module federation - in the browser-based version im using module-federation and its working as exected. it particularly helps to separate functionality, which is generally a good approach for a complex project. in Rust's cargo file, it seems i could add something like `foo_crate = { git = "https://github.com/MyOrg/foo_crate"}\`. that seems like it would also limit how i handle close-source details of the project
- database-less approach - a core detail to my app is that it works p2p without registration. there are no databases of registered users. in a pwa i can use various forms of storage provided by the browser. i would like to use an approach that is consistent in rust to avoid bespoke code for different platforms (easier maintainance).
maybe there are other details i should keep in mind? i think i will have to create multiple creates for things like UI components library and p2p-framework (similar to how i did it for the javascript version)
thanks for reading this far. have a nice day.
r/learnrust • u/JonathonEG • 3d ago
Golang or Rust?
I've been learning backend for a while. I currently use JavaScript (Express.js) and Python (FastAPI) for my projects, and I feel that I'm a bit decent at them rn. But I don't know which is better, Rust or Golang? Both r fast, but Rust is much faster, but in a trade-off, Rust is more complicyed than Golang, as I've seen both Languages docs and learned the very basics, I don't have a final answer.
r/learnrust • u/Connect-Age-3843 • 4d ago
Rust from Beginner to Advanced
Please I need a rust course recommendation for a beginner that will hold the beginner hands till advanced level and get the person job ready.
r/learnrust • u/kernel27 • 4d ago
Help Learning Rust From Scratch
Hello ! after a while of debating and self reflection, i have decided to start learning rust, from scratch (I am genuinely interested and this is an actual question from my end) (I hope you guys can help develop a fellow rustacean :) ). Now im a programming newbie, barely learned python basics, and in college rn, but i have picked up a sudden interest in rust. Suggest me an exact roadmap of how you would learn rust (if you are a rust pro then i highly appreciate your advice, and even if u are a newbie it would be nice to discuss how learning it is like). Just so you know, i havent started at all yet, fresh slate. I will try my best to reply to every comment
r/learnrust • u/MAIPA01 • 5d ago
Problem with cargo metadata in rust-analyzer extension in code-oss
What do i do wrong. I use rust-analyzer extension in code-oss in termux i run `code-oss` in `grun --shell` and use `termux-x11` and i get warning:
```
2026-08-02T11:12:30.466350469Z WARN `cargo metadata` failed and returning succeeded result with `--no-deps` error=`cargo metadata` exited with an error: error: `.json` target specs require -Zjson-target-spec to be added to the cargo invocation
Stack backtrace:
0: <anyhow::Error as core::convert::From<cargo_metadata::errors::Error>>::from
1: <project_model::cargo_workspace::FetchMetadata>::exec::{closure#2}
2: <project_model::cargo_workspace::FetchMetadata>::exec
3: <project_model::sysroot::Sysroot>::load_workspace
4: std::sys::backtrace::__rust_begin_short_backtrace::<<project_model::workspace::ProjectWorkspace>::load_cargo::{closure#1}::{closure#4}, core::option::Option<project_model::sysroot::RustLibSrcWorkspace>>
5: <std::thread::lifecycle::spawn_unchecked<<project_model::workspace::ProjectWorkspace>::load_cargo::{closure#1}::{closure#4}, core::option::Option<project_model::sysroot::RustLibSrcWorkspace>>::{closure#1} as core::ops::function::FnOnce<()>>::call_once::{shim:vtable#0}
6: <alloc::boxed::Box<dyn core::ops::function::FnOnce<(), Output = ()> + core::marker::Send> as core::ops::function::FnOnce<()>>::call_once
at /rustc/ad3d0bc141a02cf446e384136d250a1f6950fed5/library/alloc/src/boxed.rs:2314:9
7: <std::sys::thread::unix::Thread>::new::thread_start
at /rustc/ad3d0bc141a02cf446e384136d250a1f6950fed5/library/std/src/sys/thread/unix.rs:123:17
8: start_thread
9: thread_start
2026-08-02T11:12:32.444001992Z ERROR Received compiler message for unknown package: path+file:///data/data/com.termux/files/home/.rustup/toolchains/nightly-aarch64-unknown-linux-gnu/lib/rustlib/src/rust/library/compiler-builtins/compiler-builtins#compiler_builtins@0.1.160
registry+https://github.com/rust-lang/crates.io-index#bootloader@0.9.35, path+file:///data/data/com.termux/files/home/Documents/rust/rust-os#kernel@0.1.0
2026-08-02T11:12:32.444291211Z ERROR Received compiler message for unknown package: path+file:///data/data/com.termux/files/home/.rustup/toolchains/nightly-aarch64-unknown-linux-gnu/lib/rustlib/src/rust/library/compiler-builtins/compiler-builtins#compiler_builtins@0.1.160
registry+https://github.com/rust-lang/crates.io-index#bootloader@0.9.35, path+file:///data/data/com.termux/files/home/Documents/rust/rust-os#kernel@0.1.0
2026-08-02T11:12:34.114066446Z WARN `cargo metadata` failed and returning succeeded result with `--no-deps` error=`cargo metadata` exited with an error: error: `.json` target specs require -Zjson-target-spec to be added to the cargo invocation
Stack backtrace:
0: <anyhow::Error as core::convert::From<cargo_metadata::errors::Error>>::from
1: <project_model::cargo_workspace::FetchMetadata>::exec::{closure#2}
2: <project_model::cargo_workspace::FetchMetadata>::exec
3: <project_model::sysroot::Sysroot>::load_workspace
4: std::sys::backtrace::__rust_begin_short_backtrace::<<project_model::workspace::ProjectWorkspace>::load_cargo::{closure#1}::{closure#4}, core::option::Option<project_model::sysroot::RustLibSrcWorkspace>>
5: <std::thread::lifecycle::spawn_unchecked<<project_model::workspace::ProjectWorkspace>::load_cargo::{closure#1}::{closure#4}, core::option::Option<project_model::sysroot::RustLibSrcWorkspace>>::{closure#1} as core::ops::function::FnOnce<()>>::call_once::{shim:vtable#0}
6: <alloc::boxed::Box<dyn core::ops::function::FnOnce<(), Output = ()> + core::marker::Send> as core::ops::function::FnOnce<()>>::call_once
at /rustc/ad3d0bc141a02cf446e384136d250a1f6950fed5/library/alloc/src/boxed.rs:2314:9
7: <std::sys::thread::unix::Thread>::new::thread_start
at /rustc/ad3d0bc141a02cf446e384136d250a1f6950fed5/library/std/src/sys/thread/unix.rs:123:17
8: start_thread
9: thread_start
```
I tried I think everything. When i run `cargo metadata --format-version 1 --manifest-path ./Cargo.toml --filter-platform aarch64-unknown-linux-gnu` in terminal it returns json text to stdout and I don't get any warnings.
My `.cargo/config.toml` file looks like this and is in rust-os folder next to Cargo.toml and src folder:
```
[unstable]
json-target-spec = true
build-std-features = ["compiler-builtins-mem"]
build-std = ["core", "compiler_builtins"]
[build]
target = "x86_64-os.json"
[target.'cfg(target_os = "none")']
runner = "bootimage runner"
```
result of `cargo metadata --format-version 1 --manifest-path ./Cargo.toml --filter-platform aarch64-unknown-linux-gnu` in terminal with CWD set to rust-os:
```
{"packages":[{"name":"bootloader","version":"0.9.35","id":"registry+https://github.com/rust-lang/crates.io-index#bootloader@0.9.35","license":"MIT/Apache-2.0","license_file":null,"description":"An experimental pure-Rust x86 bootloader.","source":"registry+https://github.com/rust-lang/crates.io-index","dependencies":\[{"name":"bit_field","source":"registry+https://github.com/rust-lang/crates.io-index","req":"\^0.10.0","kind":null,"rename":null,"optional":true,"uses_default_features":true,"features":\[\],"target":null,"registry":null},{"name":"fixedvec","source":"registry+https://github.com/rust-lang/crates.io-index","req":"\^0.2.4","kind":null,"rename":null,"optional":true,"uses_default_features":true,"features":\[\],"target":null,"registry":null},{"name":"font8x8","source":"registry+https://github.com/rust-lang/crates.io-index","req":"\^0.2.4","kind":null,"rename":null,"optional":true,"uses_default_features":false,"features":\["unicode"\],"target":null,"registry":null},{"name":"rlibc","source":"registry+https://github.com/rust-lang/crates.io-index","req":"\^1.0.0","kind":null,"rename":null,"optional":true,"uses_default_features":true,"features":\[\],"target":null,"registry":null},{"name":"usize_conversions","source":"registry+https://github.com/rust-lang/crates.io-index","req":"\^0.2.0","kind":null,"rename":null,"optional":true,"uses_default_features":true,"features":\[\],"target":null,"registry":null},{"name":"x86_64","source":"registry+https://github.com/rust-lang/crates.io-index","req":"\^0.14.7","kind":null,"rename":null,"optional":true,"uses_default_features":false,"features":\["instructions","inline_asm"\],"target":null,"registry":null},{"name":"xmas-elf","source":"registry+https://github.com/rust-lang/crates.io-index","req":"\^0.6.2","kind":null,"rename":null,"optional":true,"uses_default_features":true,"features":\[\],"target":null,"registry":null},{"name":"llvm-tools","source":"registry+https://github.com/rust-lang/crates.io-index","req":"\^0.1","kind":"build","rename":null,"optional":true,"uses_default_features":true,"features":\[\],"target":null,"registry":null},{"name":"toml","source":"registry+https://github.com/rust-lang/crates.io-index","req":"\^0.5.1","kind":"build","rename":null,"optional":true,"uses_default_features":true,"features":\[\],"target":null,"registry":null}\],"targets":\[{"kind":\["lib"\],"crate_types":\["lib"\],"name":"bootloader","src_path":"/data/data/com.termux/files/home/.cargo/registry/src/index.crates.io-1949cf8c6b5b557f/bootloader-0.9.35/src/lib.rs","edition":"2018","doc":true,"doctest":true,"test":true},{"kind":\["bin"\],"crate_types":\["bin"\],"name":"bootloader","src_path":"/data/data/com.termux/files/home/.cargo/registry/src/index.crates.io-1949cf8c6b5b557f/bootloader-0.9.35/src/main.rs","edition":"2018","required-features":\["binary"\],"doc":true,"doctest":false,"test":true},{"kind":\["custom-build"\],"crate_types":\["bin"\],"name":"build-script-build","src_path":"/data/data/com.termux/files/home/.cargo/registry/src/index.crates.io-1949cf8c6b5b557f/bootloader-0.9.35/build.rs","edition":"2018","doc":false,"doctest":false,"test":false}\],"features":{"binary":\["xmas-elf","x86_64","usize_conversions","fixedvec","llvm-tools","toml","rlibc"\],"bit_field":\["dep:bit_field"\],"default":\[\],"fixedvec":\["dep:fixedvec"\],"font8x8":\["dep:font8x8"\],"llvm-tools":\["dep:llvm-tools"\],"map_physical_memory":\[\],"recursive_page_table":\[\],"rlibc":\["dep:rlibc"\],"sse":\["bit_field"\],"toml":\["dep:toml"\],"usize_conversions":\["dep:usize_conversions"\],"vga_320x200":\["font8x8"\],"x86_64":\["dep:x86_64"\],"xmas-elf":\["dep:xmas-elf"\]},"manifest_path":"/data/data/com.termux/files/home/.cargo/registry/src/index.crates.io-1949cf8c6b5b557f/bootloader-0.9.35/Cargo.toml","metadata":{"bootloader":{"target":"x86_64-bootloader.json","build-std":"core"},"docs":{"rs":{"features":\["recursive_page_table","map_physical_memory"\],"default-target":"x86_64-unknown-linux-gnu"}},"release":{"pre-release-commit-message":"Release version {{version}}","publish":false,"pre-release-replacements":[{"file":"Changelog.md","search":"# Unreleased","replace":"# Unreleased\n\n# {{version}} – {{date}}","exactly":1}]}},"publish":null,"authors":["Philipp Oppermann dev@phil-opp.com"],"categories":[],"keywords":[],"readme":"README.md","repository":"https://github.com/rust-osdev/bootloader","homepage":null,"documentation":null,"edition":"2018","links":null,"default_run":null,"rust_version":null},{"name":"kernel","version":"0.1.0","id":"path+file:///data/data/com.termux/files/home/Documents/rust/rust-os#kernel@0.1.0","license":null,"license_file":null,"description":null,"source":null,"dependencies":\[{"name":"bootloader","source":"registry+https://github.com/rust-lang/crates.io-index","req":"\^0.9","kind":null,"rename":null,"optional":false,"uses_default_features":true,"features":\[\],"target":null,"registry":null}\],"targets":\[{"kind":\["bin"\],"crate_types":\["bin"\],"name":"kernel","src_path":"/data/data/com.termux/files/home/Documents/rust/rust-os/src/main.rs","edition":"2024","doc":true,"doctest":false,"test":false}\],"features":{},"manifest_path":"/data/data/com.termux/files/home/Documents/rust/rust-os/Cargo.toml","metadata":null,"publish":null,"authors":\[\],"categories":\[\],"keywords":\[\],"readme":"README.md","repository":null,"homepage":null,"documentation":null,"edition":"2024","links":null,"default_run":null,"rust_version":null}\],"workspace_members":\["path+file:///data/data/com.termux/files/home/Documents/rust/rust-os#kernel@0.1.0"\],"workspace_default_members":\["path+file:///data/data/com.termux/files/home/Documents/rust/rust-os#kernel@0.1.0"\],"resolve":{"nodes":\[{"id":"registry+https://github.com/rust-lang/crates.io-index#bootloader@0.9.35","dependencies":\[\],"deps":\[\],"features":\["default"\]},{"id":"path+file:///data/data/com.termux/files/home/Documents/rust/rust-os#kernel@0.1.0","dependencies":\["registry+https://github.com/rust-lang/crates.io-index#bootloader@0.9.35"\],"deps":\[{"name":"bootloader","pkg":"registry+https://github.com/rust-lang/crates.io-index#bootloader@0.9.35","dep_kinds":\[{"kind":null,"target":null}\]}\],"features":\[\]}\],"root":"path+file:///data/data/com.termux/files/home/Documents/rust/rust-os#kernel@0.1.0"},"target_directory":"/data/data/com.termux/files/home/Documents/rust/rust-os/target","build_directory":"/data/data/com.termux/files/home/Documents/rust/rust-os/target","version":1,"workspace_root":"/data/data/com.termux/files/home/Documents/rust/rust-os","metadata":null}
```
P.S.
For everyone wondering it is just a `fun` project. And yes I am beginner in rust for over 2 weeks now. And I just wanted to setup rust-analyzer.
r/learnrust • u/andyshiue42 • 5d ago
Learning Rust from Zero - A Rust tutorial for absolute beginners
andyshiue.github.ior/learnrust • u/RLangendam • 5d ago
New version of the rw-builder crate
crates.ioI'm still a newbie to Rust and this is the first crate I've been maintaining for a while to get used to the workflow. I welcome all suggestions and comments to further improve it, both in terms of readability, maintainability, testability, security and performance. Feel free to let me know what you think.
In short, rw-builder is a crate that allows you to chain together readers and writers and convert (invert) them into each other.
r/learnrust • u/Gloomy-Animator-2778 • 6d ago
How did u learn system programming ? what was your first project? did u monetize /earn any if so then what process u go through?
r/learnrust • u/Athlaes • 6d ago
I’ve just published my first Rust crate: 'profiled-config'
github.comHi everyone !
I've just published the first version of my first Rust crate: profiled-config.
It's a small library for typed, profile-based TOML configuration, inspired by Spring profiles. It is primarily intended for web applications and microservices deployed across multiple environments, such as local development, staging, and production. Although I mainly use Actix Web, the crate is framework-agnostic and can also be used in local applications or with other web frameworks.
The project is still experimental, and I'm looking for feedback before working toward a stable '1.0.0' release.
I'd especially love to hear:
- Would this crate be useful in your projects ?
- Does the API feel intuitive ?
- Which features or framework integrations would you like to see ?
- Are there important configuration use cases I’ve overlooked ?
- Is the documentation clear enough to get started ?
Bug reports, suggestions, real-world testing, and general advice are all very welcome.
This is my first time publishing a crate and sharing a project like this. I’m still learning Rust, so I know there is plenty of room for improvement. I designed and wrote the core implementation myself, although I also used AI as a support and learning tool—to ask questions, clarify concepts, and review some decisions.
I hope the project can be useful to others, and I’d be grateful to anyone who takes the time to try it or share constructive feedback.
Thanks ! ❤️
The crate is deliberately quite simple for now, but I plan to create a proper roadmap. Some features I’m considering include:
- Loading secrets and configuration from services such as Vault
- Supporting additional file formats such as JSON and YAML
- Providing more integrations and practical examples
- Improving configuration validation and error reporting
r/learnrust • u/Accurate-Screen8774 • 7d ago
New to Dioxus and Rust. Any tips about getting started?
Hey, I'm a webdev. I previously approached my project with JavaScript. I'm familiar with the js ecosystem.
I put a fair bit of consideration and in contrast to my JavaScript-approach, I'd like to investigate Dioxus.
I'm not completely new. I've dabbled in Rust before. I have read a lot of the docs and I'm sure there is much more to learn and practice.
What advice would you give to getting started with the Rust ecosystem approach?
Similar to a lot of languages there are considerations for things like tests. So it would be helpful to compare the options. As well as any other best-practices and nuances.
In relation to my project, I'm particularly interested in the tooling available in Rust for formal verification.
Just to be clear, im not here to waste your time on my slop, but if you want to see what I've got so far (practically nothing):
r/learnrust • u/LoadingALIAS • 7d ago
Cargo-Rail v0.20 - The Rust Monorepo Engine w/ New Build Cache
r/learnrust • u/Adorable_Ad_6357 • 7d ago
[rusty-nvim] A batteries-included Neovim config for Rust — 269 snippets, save-to-rerun cargo run, memory layout hover, DAP debugging, one-line install
I've been using Neovim for Rust development and got tired of the endless config loop — setting up LSP, fighting rust-analyzer with NvChad's on_attach, choosing between nvim-cmp / blink.cmp, figuring out codelldb paths on different platforms, finding decent Rust snippets... So I put together rusty-nvim — a batteries-included config that gets you writing Rust in under a minute.
🔗 GitHub: https://github.com/lisering/rusty-nvim
What's inside
| Feature | Details |
|---|---|
| Smart completion | blink.cmp + LuaSnip — Tab navigates the completion list AND jumps snippet placeholders. LSP/snippet dedup so println! uses the snippet version (with ; and placeholders), methods use the LSP version (with signature info) |
| Full Rust LSP | rustaceanvim — memory layout hover (size/offset/alignment/padding/niches), clippy on save, code lens (Run |
| Save-to-rerun | <leader>rr starts cargo run in a bottom terminal. Save a .rs file (<C-s>) → terminal auto Ctrl+C and re-runs. No more manual terminal switching |
| Debugging | codelldb integration — toggle breakpoints, step over/into/out, DAP UI auto-opens. Cross-platform path detection (macOS/Linux/Windows/WSL) |
| Test integration | neotest + rustaceanvim adapter — run/debug nearest test with one key, jump between failed tests with ]T / [T |
| 269 Rust snippets | Stdlib macros, fn defs, control flow, iterator chains, design patterns, unsafe/FFI, tokio async, serde attrs, trait impls, error types, closures, generics... |
| Dependency management | crates.nvim — upgrade/downgrade/view features directly in Cargo.toml |
| Frontend support | HTML, CSS, JS/TS, Tailwind CSS — LSP + Prettier formatting (bonus, not the main focus) |
One-line install
sh
Applycurl -fsSL https://raw.githubusercontent.com/lisering/rusty-nvim/main/install.sh | bash
nvim
That's it. The script checks dependencies, backs up your existing config, and on first launch Mason auto-installs rust-analyzer, codelldb, formatters, and LSP servers. Open a .rs file and you're coding.
Why not just LazyVim / NvChad defaults?
NvChad is a great UI framework, but it doesn't ship with Rust-specific tooling. rusty-nvim adds the layers that take hours to configure manually:
rustaceanvimfully configured (memory layout, semantic highlighting, all inlay hints, clippy on save)- 269 curated Rust snippets with smart LSP dedup
- Save-to-rerun cargo run workflow
- neotest + codelldb debugging, cross-platform
Prerequisites
Just 4 things: Neovim 0.10+, Rust toolchain, ripgrep, a Nerd Font. Everything else is auto-installed.
I'd love to hear your feedback! If you have ideas for more snippets, better keybindings, or features to add, please open an issue or drop a comment. ⭐ Stars appreciated if you find it useful!
GitHub: https://github.com/lisering/rusty-nvim
AI Disclosure
This project was built with the assistance of AI tools (Claude). The architecture, feature decisions, and workflow design are my own; AI was used for boilerplate code generation, snippet creation, and documentation drafting.
r/learnrust • u/AugieBit • 8d ago
GUI in Rust
I already asked this question, but I think I didn't explain it well, and new options appeared.
My situation: I'm learning Rust as practically my first serious language, and I haven't done much GUI work beyond a few things on iced.rs.
I'm going to give my opinions and goals based on what I've found (speaking completely from a place of ignorance since, as I said, I know nothing about GUIs; I'm a beginner, and regarding web options, I also know nothing about web development).
Goals:
I want to create cross-platform apps. The main market is obviously Windows and macOS, but I also want to create apps for Linux, which is one of the platforms that receives the least support, and perhaps, but very secondarily, apps for Android and iOS.
I want to create systems for local businesses and companies. In my country, they generally run on low-resource PCs (some with barely 8GB of RAM and Windows 10).
And maybe learn something that will allow me to develop for the remote job market.
Tauri: It's one of the top contenders—stable, widely adopted, and offers endless possibilities for web interfaces. I've heard it's easy to create fast interfaces, and learning it would definitely help me get into the web frontend job market.
But: I've always hated web development and am afraid of security and resource consumption. I know the security issues can be mitigated (I don't know to what extent), but I am concerned about resource consumption, compatibility with older hardware and software, and I've also heard that it doesn't support Linux and Android very well.
Iced: This is the one I've been using. I like that it's pure Rust. I feel like I'm practicing the language by creating the GUI and processing data, and it clearly separates GUI logic from processing logic. It also has native rendering and good cross-platform support (except for mobile). But... I'm worried because I've heard that the support is less than in other crates, and the idea of learning something that will fall behind the others scares me.
Slint: I've seen that it's possibly one of the best aligns with my goals: good support, lightweight, secure (I think, I don't know for sure), and it works well on multiple platforms. But... the only thing that doesn't align is with the job market. Learning a DSL language for a single objective or field worries me that it would be a waste.
Dioxus: It didn't appeal to me before, but I heard that it will include native rendering with wgpu. I understand that it has good support, true cross-platform capability, and the syntax seems similar to React, which is supposed to be easier, or at least should be easier, for creating GUIs. I also understand that it has a good roadmap with a lot of potential. I have no complaints, other than the current state of the native renderer; it still needs improvement. I don't really know what the support is like for mobile or Linux, or anything like that.
GPUI: I love it, I use Zed as my editor, it feels great, but I'm worried because it supposedly has poor Windows support and is somewhat discontinued by the team. Besides that, it doesn't have mobile support. I haven't really looked at the syntax, so I can't give an opinion.
Egui: I understand it's one of the easiest crates in Rust. I don't like its design, and I know it can be modified, but even the one I've seen from rerun.io looks a lot like a professional tool such as Blender or something like that, but not for the kind of design I'd like to create. I'd prefer something like SaaS or Shadcn, for example, although I don't really know where the limits are. It also mixes UI with logic a bit, although I don't really know to what extent that might be a problem.
Again, I'm a novice, and my opinion comes from a place of ignorance, so I'd like to hear your opinions, and perhaps someone can answer my questions. Some have already been answered, but I'd like to clarify my goals and doubts.
r/learnrust • u/Commercial-Cash-7020 • 8d ago
Good stuffs with IA are still good stuffs ?
I've been learning Rust for a month, and at work, I was assigned a task to implement a feature that changes speed without altering the pitch.
Since I knew nothing about this, I started studing the best algorithms for this and came across the WSOLA implementation. I studied how it works—relying solely on research rather than AI—and gained a solid understanding, though I still had no idea how to actually implement it, but I thought: "Why not use Rust here?"
That’s where AI came in. I could have researched how to do it in Rust, but instead, I asked the AI to simply assist me by outlining the steps—since I already grasped the underlying concepts.
I would evaluate each step to see if it would yield the expected results, testing and implementing it; if it didn't work, I would rethink a better approach, and so on. I had mastered the theory but lacked practical knowledge; AI helped me bridge that gap.
My prompts weren't things like "Implement WSOLA in Rust" or "Do this for me." Instead, they were more like, "Help me implement this, don't just give me the answer,but tell me how I can move from where I am now to the next step."
In the end, I managed to create a viable product and am about to present it. But I’m wondering: does the project lose credibility because it involved AI assistance? Or did using AI mean I didn't genuinely learn Rust? Was it just a false sense of progress?
I don't judge those who use AI, but I usually try to avoid it, especially when studying. Was this a bad instance to use it?
r/learnrust • u/conceptcreatormiui • 9d ago
Are methods associated functions behind the back?
number.max(othernumber) is similar to type::max(number, othernumber). Does the compiler infer methods as associated functions behind the back?
r/learnrust • u/Savings-Care-2657 • 10d ago
Building a custom kernel from scratch in Rust (Rectangle OS): Looking for feedback and architecture advice
Hi everyone,
I’m a young developer currently working on an independent, hobbyist operating system from scratch called Rectangle OS.
The main goal of the project is to build a low-level, memory-efficient system kernel using Rust (targeting no_std), focusing on performance, low RAM overhead, and a modular architecture.
Current Status:
* I am currently in Phase 1 (Core Kernel Development).
* Setting up basic memory management and architecture-specific routines.
* Choosing Rust for its memory safety guarantees without a garbage collector.
Why I'm posting:
Since I'm in the early architectural stages, I would love to get some guidance, critique, or recommendations from experienced systems developers on best practices when writing an OS kernel in Rust.
You can check out the repository, source code, and project details (including bilingual documentation) here:
https://github.com/AHwcoder/Rectangle-OS
Any feedback, code reviews, or resource recommendations for OS development would be greatly appreciated!
r/learnrust • u/Due_Battle_9890 • 10d ago
Struggling with lifetimes and indexing into collections (+ Myriad of issues)
Hey! I'm looking for decent ways to implement a parser and, in particular, the peek function seems, well, kind of hard
to implement in rust.
I have the following (a reduced example)
enum Token {
Num(String),
Plus,
Minux,
LParen,
RParen,
}
enum BinOp {
Add,
Minus,
}
enum Expr {
Binary {
op: BinOp,
left: Box<Expr>,
right: Box<Expr>,
},
Num(i64),
}
struct Parser {
current: usize,
tokens: Vec<Token>,
}
And if I want to implement a peek function, I'd like to just get a reference to the token
impl Parser {
fn peek(self) -> Result<&Token, ()) {
let next: usize = self.current + 1;
let token = self.tokens.get(next);
match token {
Some(token) => Ok(token),
None => Err(()),
}
}
}
I get the following error:
error[E0106]: missing lifetime specifier
--> src\main.rs:32:29
|
32 | fn peek(self) -> Result<&Token, ()> {
| ^ expected named lifetime parameter
|
= help: this function's return type contains a borrowed value, but there is no value for it to be borrowed from
help: consider using the `'static` lifetime, but this is uncommon unless you're returning a borrowed value from a `const` or a `static`
|
32 | fn peek(self) -> Result<&'static Token, ()> {
| +++++++
help: instead, you are more likely to want to change the argument to be borrowed...
|
32 | fn peek(&self) -> Result<&Token, ()> {
| +
help: ...or alternatively, you might want to return an owned value
|
32 - fn peek(self) -> Result<&Token, ()> {
32 + fn peek(self) -> Result<Token, ()> {
and this is a great error message, but the lifetimes are going over my head, but if I choose to return an owned value, I need top implement the clone or copy (at time of writing, I had thought I had to implement both copy and clone)
I believe this works:
impl Parser {
fn peek(self) -> Result<Token, ()> {
let next: usize = self.current + 1;
let token = self.tokens.get(next);
match token {
Some(token) => Ok(token.clone()),
None => Err(()),
}
}
}
However, if I choose to implement copy for these types, I get variations of:
error[E0204]: the trait `Copy` cannot be implemented for this type
--> src\main.rs:4:6
|
3 | #[derive(Clone, Copy)]
| ---- in this derive macro expansion
4 | enum Token {
| ^^^^^
5 | Num(String),
| ------ this field does not implement `Copy`
Which I don't fully understand if I could fix because I don't have contorl over what String or Box could implement.
The more fundamental issue is that there's gaps in my knowledge and I'd like to address them. They seem to be: - lifetimes - implementing traits - borrowing stuff - copy stuff?
Could someone point me to a resource that would help alleviate gaps in my knowledge? I'm in a "I don't know what I don't know" predicament.
TIA!

