Intermediate and advanced Rust programming language | Advanced Rust tutorial in 8 hours
This 8-hour video covers a number of intermediate and advanced concepts of Rust programming language. We will discuss the following concepts: generic data types and traits, lifetime of references, automated tests, closures and iterators, smart pointers, concurrency, attributes, unsafe Rust, advanced traits, derivable traits. 00:00:00 - Continuation of introductory Rust video The references used in this video are listed as well. 00:00:38 - Generic data types and traits Generic data types work in functions, enums, structs, and methods, allowing concrete types to be inserted. Traits, which group methods for an unknown type (self), can be implemented on any data type. A function can accept a type that implements a trait as a parameter, or return a struct or enum that implements a trait. 00:38:38 - Lifetime of references Lifetime helps us to make sure that the references used are valid as long as we need to use them at runtime. We will discuss borrow checker, lifetime annotation, lifetime elision rules, and static lifetimes. 01:05:45 - Exercise 1: Generic data types, traits and lifetimes 01:28:06 - Display trait We can implement the fmt::Display trait manually to print the content of the data type. 01:32:21 - Automated tests Rust provides a built-in testing framework, making it easy to write and run tests without additional dependencies. We can make assertions to the return value of a test function, and then test this assertion. The test result can be a panic macro, or a Result enum variant. Rust allows both the unit test and the integration tests. 02:08:26 - Closures and iterators In Rust, a closure is a flexible anonymous function that can capture values from its surrounding scope, be stored in variables, and be passed as arguments to other functions. There are 3 traits that a closure can implement to handle the captured values: Fn, FnOnce, FnMut. Iterators can help us handle the logic required in doing iterations in an iterable. We will also discuss the iterating adapters and consuming adapters. 02:54:55 - Exercise 2: Closures and iterators 03:03:11 - Smart pointers We will discuss the Box pointer, and Deref trait that can obtain the value wrapped by a Box pointer. The Drop trait would help us decide what to do when a Box pointer is out of scope. We will also discuss the reference counted (Rc) pointer RefCell pointer. We will talk about the problem with reference cycles. Finally, a trait object enables a reference to any type that implements a specific trait, providing flexibility for polymorphism without knowing the exact type at compile time. 04:39:54 - Exercise 3: Trait objects 04:58:59 - Concurrency An obvious way is to make use of threads to achieve concurrency in Rust. Another way of achieving concurrency is message passing. A channel can be made to allow the transfer of data from a transmitter to a receiver. The third way is to perform shared-state concurrency. Multiple threads can access the same piece of data in the memory at the same time by using Mutex mechanism. 05:36:33 - Attributes An attribute is a metadata that is put on some module or item. There are many purposes of using attributes. We will discuss the use of inner and outer attributes. An attribute can allow for conditional compilation of the code. An attribute can also disable warnings. An attribute can also mark a function as a unit test. 05:47:40 - Advanced features of Rust One advanced feature is unsafe Rust. We can use unsafe code to override the strict memory safety issue. Another advanced feature is advanced traits. Such traits contain an associated type, which is a type placeholder in a trait that the methods can use. There are also advanced types in Rust, such as the Newtype pattern, never type, and dynamically sized types. 07:20:22 - Derivable traits We will discuss a number of traits such as the Clone trait, Copy trait, Debug trait and Default trait. English subtitles are available for viewers to choose. Visual Studio Code theme: Bluloco Light Theme by Umut Topuzoğlu Photo by Mickey O'neil on Unsplash Declaration: This video is not affiliated with Rust Foundation. The creator of this video is not a member of Rust Foundation. Playlist of my JavaScript course https://www.youtube.com/playlist?list=PLtQo0sxRN7JJQzQV_p_9RKy1eXVEmUIRl Playlist of my HTML5 and CSS3 tutorials https://www.youtube.com/playlist?list=PLtQo0sxRN7JIENxPo4cVWN8wbOjQZE3MX Playlist of my algorithm walkthrough https://www.youtube.com/playlist?list=PLtQo0sxRN7JLcH6q-PeqLz6ZtnYpDa4ul Playlist of my Java course https://www.youtube.com/playlist?list=PLtQo0sxRN7JLr647f8RTzS58u8Rv5jxT5 Playlist of my Java examples https://www.youtube.com/playlist?list=PLtQo0sxRN7JKKla3_GAF05dySjyy3nINa Playlist of my Python projects for beginners https://studio.youtube.com/playlist/PLtQo0sxRN7JIlRfXK9RLTL_vtSnaxjLFt/edit #rustforprogrammers #rustlang #rustprogramming #rustdevelopment #rusttutorial
Download
0 formatsNo download links available.