Rust Code for learning purposes

I am learning Rust these days. I wanted a Rust open source project that is well documented/ commented so that I may read the code and learn from that code.

The mini-redis project was built with the intention of being a learning resource.


Are you interested in graphics? If so, then I would suggest GitHub - emilk/egui: egui: an easy-to-use immediate mode GUI in Rust that runs on both web and native. ( Even if you are not interested in graphics the source has many things to teach you. wasm for example. ) The demo egui – An immediate mode GUI written in Rust has a lot of variety and the sources are easy to read.
If you start in the egui_demo_app directory and look at the src directory you will see two files, and
The file is if you are making a native app. See how it calls the stuff in the "egui_demo_lib" folder, it has a main function that calls eframe::run_native

 fn main() {
    let app = egui_demo_lib::WrapApp::default();
    let options = eframe::NativeOptions {
        // Let's show off that we support transparent windows
        transparent: true,
        drag_and_drop_support: true,
    eframe::run_native(Box::new(app), options);

The file is if you are making wasm. It works with java and sets some callback. See how it calls the stuff in the "egui_demo_lib" folder, it has a function called start that gets called by the java framework. Magic from bindgen. The start() function calls the app with eframe::strart_web.

pub fn start(canvas_id: &str) -> Result<(), wasm_bindgen::JsValue> {
    let app = egui_demo_lib::WrapApp::default();
    eframe::start_web(canvas_id, Box::new(app))

After you read those two files, go inside of the egui_demo_lib folder and see the file. The demos are inside the apps folder.
The sources are all pretty short )?( and not too complicated. There are some confusing things you will learn as you crawl through. If you find something you can not figure out, come here and ask..
Before and during your time perusing the sources do this to get yourself "rusty"

Get the demo app to run as native to get your cargo skill up to par.
Get it to run as wasm to get your other skills up to par. (You will need to figure out how to get it to build...Get a server working, etc.)

After you get it to run..

Pick a demo (I picked the fractal clock) and read the source enough to understand what it does.
Modify the demo you choose and try to get it to compile with your changes.

Then pick another demo and to the same thing.

If you want to keep going with the egui way of doing graphics then get the egui_template sources and go from there.

** Update **
My details above are a bit off. My egui source is back in time to last year, commit 78dfde40 and I see the current sources have been moved / refactored.


Great stonefish,

I am really thankful for your so much time and explanation. I will defiantly give it a try. thanks once again

Have you tried rustlings

1 Like

Thanks Michael,

Actually I am looking for a full project with annotated comments for clarity. It is also a good resource for learning purposes BTW.

For sure do not skip rustlings and rust by example. even if they are not "interesting" to you. One or two chapters at a time. Just so you go through and see all the stuff that can happen.


This topic was automatically closed 90 days after the last reply. We invite you to open a new topic if you have further questions or comments.