Keyboard shortcuts

Press or to navigate between chapters

Press S or / to search in the book

Press ? to show this help

Press Esc to hide this help

Rust Programming Fundamentals is a collection of runnable examples designed to illustrate core Rust concepts and the use of its standard library. Each example is crafted to not only demonstrate syntax, but also to highlight practical use cases, best practices, and common programming patterns. By experimenting with and modifying these examples, learners can gain a deeper understanding of Rust’s unique features—such as ownership, borrowing, lifetimes, concurrency, and error handling. To get even more out of these examples, readers are encouraged to run them in their own development environment, tweak the code, and observe how small changes can affect program behavior. This hands-on approach transforms passive reading into active learning, making the journey into Rust both engaging and effective.

Now let's begin!

  • Hello World - Start with a traditional Hello World program.

  • Primitives - Learn about signed integers, unsigned integers and other primitives.

  • Custom Types - struct and enum.

  • Variable Bindings - mutable bindings, scope, shadowing.

  • Types - Learn about changing and defining types.

  • Conversion - Convert between different types, such as strings, integers, and floats.

  • Expressions - Learn about Expressions & how to use them.

  • Flow of Control - if/else, for, and others.

  • Functions - Learn about Methods, Closures and Higher Order Functions.

  • Modules - Organize code using modules

  • Crates - A crate is a compilation unit in Rust. Learn to create a library.

  • Cargo - Go through some basic features of the official Rust package management tool.

  • Attributes - An attribute is metadata applied to some module, crate or item.

  • Generics - Learn about writing a function or data type which can work for multiple types of arguments.

  • Scoping rules - Scopes play an important part in ownership, borrowing, and lifetimes.

  • Traits - A trait is a collection of methods defined for an unknown type: Self

  • Macros - Macros are a way of writing code that writes other code, which is known as metaprogramming.

  • Error handling - Learn Rust way of handling failures.

  • Std library types - Learn about some custom types provided by std library.

  • Std misc - More custom types for file handling, threads.

  • Testing - All sorts of testing in Rust.

  • Unsafe Operations - Learn about entering a block of unsafe operations.

  • Compatibility - Handling Rust's evolution and potential compatibility issues.