
Explore Rust, a systems programming language that matches C and C++ performance with memory safety and concurrency, without a garbage collector, via ownership, move, and borrowing.
Learn string concatenation in Rust using the + operator and internal add() function, and explore building strings with the format macro and practical formatting examples.
Explore decision making in Rust through if statements, if-else chains, nested blocks, and match statements, with practical examples of conditions, branches, and control flow.
General Introduction . Rust is for Systems programming. Systems programming is used Operating Systems, Networking, File systems, Databases , Cryptography and much more. Rust is very popular with Concurrency, memory safety at compile time, and multithreaded applications and type safety. Variables and mutability. By default variables are immutable in Rust. There is a concept called shadowing in Rust. We use println!() macro for printing. Macros are an extended version of functions. Data types. Automatic type casting is not allowed in Rust. Number separator for large numbers using underscores possible in Rust. The mut keyword is used for mutability. Rust strings are divided into string literals and string objects. Match statement is used in Rust like the switch case statement in C/C++. For returning values from functions we can use a single arrow --> like this to indicate a return type.
Parameters are passed to functions by value as well as by Reference as in other languages. There is a concept called Rust Ownership. The move operation in Rust is similar to a shallow copy in other languages. We have the stack memory as well as the Heap memory. Rust trait is very much similar to the concept of interfaces in Object oriented programming languages. There is a concept called copy trait in Rust.
Rust References and Borrowing. Observe Rust does not have the idea of Garbage collection. There is nothing like Exception handling also in Rust. Rust slices. A slice is a pointer to a block of memory. String slices are literals. Rust structure is similar to structures in other languages. Rust has Enums as well as Modules. Rust collections include Vector, Hash Map and Hash Set. Rust Error handling . Recoverable and Unrecoverable errors in Rust. Panic macro and Unrecoverable errors. Generic types, Generic structures.