Part of the Rust Crash Course: https://www.youtube.com/playlist?list=PL6yRaaP0WPkWRsXJgdnw9lj1vchAaKwfS

Welcome to the Rust Crash Course

In this course, we will be learning Rust from scratch. This course is very fast paced and designed for programmers who already have some experience with another programming language such as Dart or JavaScript or Swift. We will talk about variables, constants, ownership, functions, structures, enumerations, collections such as tuples, vectors, hash-maps and iterators, optionals, error handling, lifetime specifiers, traits, pointers, generics, packages, crates, modules and paths, asynchronous programming and we will also create 2 sample applications using Rust to put all these concepts to use!

Generics allow you to create reusable pieces of code without caring too much about the data-types that you work with. In this chapter we will work with generics in Rust and put their power of reusability into practice.

Timestamps:
00:00 - Generics
00:59 - Create a Point structure
01:09 - This structure accepts only integers
01:37 - Create a valid instance of Point
01:54 - Create an invalid instance of Point
02:51 - Time to create a generic point
02:59 - Now your code compiles
03:19 - This means you can create points of strings
04:15 - Prematurely implement "move_offset" on Point T
04:27 - You will now get compile errors
05:21 - Import AddAssign
05:45 - Fix the implementation of move_offset
06:26 - Create a mutable instance of point now
06:45 - Move the point by an offset
07:53 - You can implement AddAssign on Point itself
07:58 - impl T: AddAssign AddAssign for Point T
08:14 - Now you can implement add_assign
09:02 - Create a mutable point
09:06 - Create an immutable one
09:23 - You can now mutate "p1" with AddAssign
10:04 - You can add upon this with PartialEq
10:39 - Add PartialEq to Point
10:49 - Implement the "eq" function itself
11:42 - Put it to test
12:15 - Traits and generics go very much hand in hand
12:34 - Create a "run" trait
12:45 - Create a "walk" trait
13:23 - Implement "CanRun" for Vec
14:09 - Implement "CanWalk" for Vec
14:30 - Now define a Person struct
14:40 - Implement CanWalk and CanRun for Person
15:25 - Define Elephant that cannot run
15:33 - Implement CanWalk for Elephant
15:57 - Define your test objects


If you want to support my work, please consider joining my YouTube channel by pressing the Join button!

Twitter: https://twitter.com/vandadnp
LinkedIn: https://linkedin.com/in/vandadnp

Let's get started!