1 00:00:05,900 --> 00:00:08,420 We can pass traits as parameters as well. 2 00:00:08,810 --> 00:00:14,450 In the earlier examples, we implemented the trait overview for both course and another course. 3 00:00:14,450 --> 00:00:20,000 So let's create a function that's going to call the overview method from its item parameter. 4 00:00:20,240 --> 00:00:25,550 So the first thing we need to do is create that function. 5 00:00:27,620 --> 00:00:33,590 We're going to give it the item parameter that's going to have a reference to the overview implementation. 6 00:00:35,200 --> 00:00:39,910 And then in here we're just going to print out overview 7 00:00:42,490 --> 00:00:44,650 and then item dot overview. 8 00:00:45,550 --> 00:00:53,440 So since we already have these two types created that implement the overview method, we can call them. 9 00:00:53,440 --> 00:00:54,700 So we'll call course one. 10 00:00:54,700 --> 00:01:01,930 And of course we need to pass it by reference and then we can also do this for course to. 11 00:01:05,330 --> 00:01:12,530 So we run it and we see this is a rust course, which is of course one and also the default implementation. 12 00:01:12,530 --> 00:01:17,180 And then we have our modified course, which is another tiler, another headline. 13 00:01:17,180 --> 00:01:17,930 So awesome. 14 00:01:17,930 --> 00:01:19,100 So that's working good. 15 00:01:19,340 --> 00:01:29,960 But we can actually simplify the function and what we can do is come in here and say a type of overview. 16 00:01:32,250 --> 00:01:35,400 And then we can just change all of this right here. 17 00:01:37,420 --> 00:01:39,690 Did you say a reference to type? 18 00:01:40,680 --> 00:01:41,970 And it's the same exact thing. 19 00:01:42,840 --> 00:01:43,440 So. 20 00:01:44,340 --> 00:01:52,290 The first way we did it is convenient and makes for more concise code and simple cases, whereas what 21 00:01:52,290 --> 00:01:56,580 we have implemented now can express more complexity. 22 00:01:58,280 --> 00:01:59,780 A little bit more clearly. 23 00:02:01,850 --> 00:02:03,020 Also the. 24 00:02:03,980 --> 00:02:09,440 Replacement Station overview works for straightforward cases. 25 00:02:09,440 --> 00:02:13,910 So what I'm referring to now is what we did in the earlier case. 26 00:02:13,910 --> 00:02:15,260 So let me go back to that. 27 00:02:17,270 --> 00:02:20,240 So the implement overview. 28 00:02:22,060 --> 00:02:22,910 Get rid of the air. 29 00:02:22,930 --> 00:02:29,580 The implement overview works for straightforward cases, but is actually just shorthand for a trait 30 00:02:29,590 --> 00:02:30,290 bounce. 31 00:02:30,310 --> 00:02:37,270 So let's look at some different trait patterns and I'm just going to have all these commented in that 32 00:02:37,270 --> 00:02:37,420 way. 33 00:02:37,420 --> 00:02:40,060 We can just kind of see everything side by side. 34 00:02:40,060 --> 00:02:48,760 So the first one is going to be if we had the overview function, we had item one and it was. 35 00:02:51,010 --> 00:02:55,270 You know, implementing in the overview trait. 36 00:02:55,270 --> 00:02:58,360 And then item two also implements 37 00:03:02,170 --> 00:03:03,190 the overview trait. 38 00:03:04,320 --> 00:03:12,180 So this allows item one and item two to be of different types, but we can force them to be of the same 39 00:03:12,180 --> 00:03:13,590 type if we want it to. 40 00:03:13,740 --> 00:03:18,060 And that's where the method that we just had comes into play. 41 00:03:18,060 --> 00:03:24,480 So we can say overview again, but this time t of overview. 42 00:03:25,900 --> 00:03:35,050 And now it's going to be item one and T and then item to A and T as well. 43 00:03:35,680 --> 00:03:41,230 So again, these are the same thing, but this one can have different types. 44 00:03:41,230 --> 00:03:45,430 And this one, we are making them have to be the same type. 45 00:03:47,950 --> 00:03:52,240 And then the last thing we can do is we can have multiple trade bounds and this is done 46 00:03:55,180 --> 00:03:55,990 this way. 47 00:03:56,410 --> 00:03:58,510 So we created our function again. 48 00:03:58,510 --> 00:04:05,770 We're passing in item one and we're going to implement an overview. 49 00:04:07,860 --> 00:04:12,210 And then plus and then our other trait. 50 00:04:12,570 --> 00:04:17,790 So plus another trait allows us to have multiple trait bounds. 51 00:04:18,730 --> 00:04:20,620 And then just to keep everything uniform. 52 00:04:20,620 --> 00:04:25,020 If we wanted to see this in the other way, it would be t. 53 00:04:25,570 --> 00:04:30,100 Overview plus another trait. 54 00:04:31,450 --> 00:04:33,040 And then we have item one. 55 00:04:33,970 --> 00:04:36,070 Anti item to. 56 00:04:37,830 --> 00:04:42,570 Anti and that's going to make them have to be of the same type. 57 00:04:42,600 --> 00:04:47,970 So with all of that, I just wanted to show you some extra functionality we can use traits for and I 58 00:04:47,970 --> 00:04:49,020 hope it all make sense. 59 00:04:50,050 --> 00:04:55,930 I know we've learned a lot about genetics and traits so far in this section, so just take a second 60 00:04:55,930 --> 00:05:01,060 to make sure you fully understand everything before continuing on to the next lecture where we will 61 00:05:01,060 --> 00:05:03,580 start talking about utility traits.