1 00:00:06,690 --> 00:00:09,360 - Hello again and welcome to lesson 13. 2 00:00:09,360 --> 00:00:11,820 This lesson is all about generics. 3 00:00:11,820 --> 00:00:13,500 We begin with the basic syntax 4 00:00:13,500 --> 00:00:16,470 for generic structures and generic functions. 5 00:00:16,470 --> 00:00:18,933 We'll see how to define them and how to use them. 6 00:00:19,860 --> 00:00:22,890 Then, we'll move on to discuss type constraints. 7 00:00:22,890 --> 00:00:26,010 Type constraints enable you to specify basic requirements 8 00:00:26,010 --> 00:00:27,570 for type parameters. 9 00:00:27,570 --> 00:00:30,390 For example, you can specify a type parameter 10 00:00:30,390 --> 00:00:33,810 must implement a certain trait, so you can then depend 11 00:00:33,810 --> 00:00:36,693 on that trait's functionality in your generic code. 12 00:00:38,760 --> 00:00:40,830 For the remainder of the lesson, we'll take a look 13 00:00:40,830 --> 00:00:44,310 at some of the standard generic traits in the Rust library. 14 00:00:44,310 --> 00:00:45,143 We'll take a look 15 00:00:45,143 --> 00:00:49,380 at generic traits named PartialEq, Eq, Hash, 16 00:00:49,380 --> 00:00:53,310 PartialOrd and Ord, cryptic names I know. 17 00:00:53,310 --> 00:00:55,230 We discuss their role in Rust 18 00:00:55,230 --> 00:00:58,740 and we'll see how to implement them in your structures. 19 00:00:58,740 --> 00:01:00,840 We'll wrap up the lesson with a closer look 20 00:01:00,840 --> 00:01:04,800 at how closures work internally inside Rust. 21 00:01:04,800 --> 00:01:07,710 It so happens that when you write a closure, 22 00:01:07,710 --> 00:01:08,640 Rust converts it 23 00:01:08,640 --> 00:01:12,210 into a strap that implements a generic trait. 24 00:01:12,210 --> 00:01:14,310 This enables you to pass closures 25 00:01:14,310 --> 00:01:17,373 as parameters into function, as we shall see.