1 00:00:06,210 --> 00:00:13,890 It is possible for structs to hold references, but when we do that, we need to add a lifetime annotation 2 00:00:13,890 --> 00:00:15,870 on every reference we created. 3 00:00:16,020 --> 00:00:18,510 So let's quickly create a new structure. 4 00:00:18,540 --> 00:00:20,430 We're going to call it my string. 5 00:00:21,630 --> 00:00:30,300 And then inside of here, we're going to add a text field and we'll give it a reference to a string 6 00:00:30,300 --> 00:00:37,050 slice so we can tell that we already are getting an error and it says we're missing a lifetime parameter, 7 00:00:37,050 --> 00:00:39,690 so let's give it one. 8 00:00:39,870 --> 00:00:44,370 And then also up here, we're going to have to declare it. 9 00:00:44,370 --> 00:00:47,520 So now everything is happy. 10 00:00:47,850 --> 00:00:50,100 But why do we have to do this? 11 00:00:50,370 --> 00:00:56,550 Well, we have to do this because when we create an instance of my string, which let's just go ahead 12 00:00:56,550 --> 00:00:57,390 and do that. 13 00:00:57,630 --> 00:01:10,560 So we'll create a string from and then this is my string and then we're going to create an X, which 14 00:01:10,560 --> 00:01:22,260 is going to be my string instance and we're going to set it text store one dot as string slice. 15 00:01:22,920 --> 00:01:27,450 So we have to implicitly. 16 00:01:28,480 --> 00:01:39,490 Explicitly declare the lifetime because we want to make sure that the instance of my string cannot outlive 17 00:01:39,490 --> 00:01:44,470 the reference it holds in its text field, which in this case is string one. 18 00:01:44,470 --> 00:01:51,070 Because if my string lives longer than the string we created here, which is what we passed in as a 19 00:01:51,070 --> 00:01:56,590 string slice, then we would end up having a dangling reference up here. 20 00:01:56,770 --> 00:02:03,730 So that's just a really good example of why lifetime annotations are important and how they're going 21 00:02:03,730 --> 00:02:08,950 to help us prevent our code from having dangling references.