1 00:00:06,480 --> 00:00:09,390 - So far, we've seen how to define simple enums types. 2 00:00:09,390 --> 00:00:10,590 Like you can see, here, 3 00:00:10,590 --> 00:00:12,900 I've defined an enum type called color, 4 00:00:12,900 --> 00:00:15,270 and I've just given it some variance. 5 00:00:15,270 --> 00:00:17,760 When you declare an enum like this, 6 00:00:17,760 --> 00:00:20,250 effectively, it's just a simple flag. 7 00:00:20,250 --> 00:00:22,770 You're saying that this concept of a color 8 00:00:22,770 --> 00:00:25,020 can either be in the state of red 9 00:00:25,020 --> 00:00:27,510 or the state of green or the state of blue. 10 00:00:27,510 --> 00:00:30,930 It's just a flag to indicate what state 11 00:00:30,930 --> 00:00:32,433 the variable is currently in. 12 00:00:33,330 --> 00:00:38,070 It's also possible to associate data values with variants. 13 00:00:38,070 --> 00:00:41,520 Each variant can also represent a number. 14 00:00:41,520 --> 00:00:45,330 So in that case, the variant is like a flag, 15 00:00:45,330 --> 00:00:47,490 and if a value has that variant, 16 00:00:47,490 --> 00:00:50,130 it has the associated type of data. 17 00:00:50,130 --> 00:00:53,670 So in this example here, I've set a house location. 18 00:00:53,670 --> 00:00:55,410 If you wanted to know somebody's house location, 19 00:00:55,410 --> 00:00:59,100 where they live, the house location could either be 20 00:00:59,100 --> 00:01:01,350 the number variant, in which case, 21 00:01:01,350 --> 00:01:04,290 you can get back the value, an integer 32 value, 22 00:01:04,290 --> 00:01:08,340 their house number, or the house location could be 23 00:01:08,340 --> 00:01:10,740 that name of the house, in which case, 24 00:01:10,740 --> 00:01:12,570 you could get back a string, 25 00:01:12,570 --> 00:01:14,880 the name of the house that the person lives, 26 00:01:14,880 --> 00:01:17,583 or the house location could be unknown. 27 00:01:18,690 --> 00:01:22,053 So when you declare a house location variable, 28 00:01:22,980 --> 00:01:25,473 it could hold a value like this. 29 00:01:26,370 --> 00:01:30,450 It could hold the number variant, okay? 30 00:01:32,970 --> 00:01:36,180 In which case, the value inside the enum 31 00:01:36,180 --> 00:01:40,987 would be the house number like the number four as an i32. 32 00:01:42,060 --> 00:01:43,380 We live in house number four. 33 00:01:43,380 --> 00:01:47,430 I'm currently sitting in house number four in my home 34 00:01:47,430 --> 00:01:50,407 or, alternatively, the house location 35 00:01:50,407 --> 00:01:53,610 could have the variant name. 36 00:01:53,610 --> 00:01:55,680 So the variant is like a flag 37 00:01:55,680 --> 00:01:59,460 which indicates what can value it currently contains. 38 00:01:59,460 --> 00:02:02,070 If the house location has the name variant, 39 00:02:02,070 --> 00:02:06,090 then the current value would be a string, okay? 40 00:02:06,090 --> 00:02:08,940 So the example I'm gonna show you, 41 00:02:08,940 --> 00:02:11,586 let's say your house name is called cartref. 42 00:02:11,586 --> 00:02:15,060 Cartref is the Welsh word for home. 43 00:02:15,060 --> 00:02:17,490 So here I live in Swansea, 44 00:02:17,490 --> 00:02:22,007 you see quite a lot of houses called cartref, my home, 45 00:02:22,007 --> 00:02:27,007 or, alternatively, the house location for a person could be, 46 00:02:27,469 --> 00:02:30,510 it could have the variant unknown, 47 00:02:30,510 --> 00:02:32,580 in which case, it doesn't have 48 00:02:32,580 --> 00:02:36,090 any data associated with it at the moment. 49 00:02:36,090 --> 00:02:38,493 It just has the unknown flag. 50 00:02:39,810 --> 00:02:44,310 So it gives you the option of saying what kind of value 51 00:02:44,310 --> 00:02:47,430 you currently contain, and what is that value? 52 00:02:47,430 --> 00:02:49,770 What kind of value do you currently contain 53 00:02:49,770 --> 00:02:51,510 and what is that value? 54 00:02:51,510 --> 00:02:53,850 So that's quite powerful, 55 00:02:53,850 --> 00:02:56,070 an enum, not only says what state it's in, 56 00:02:56,070 --> 00:02:59,040 but it conveys a value for that state, 57 00:02:59,040 --> 00:03:03,420 a number, a string or nothing at all, 58 00:03:03,420 --> 00:03:07,590 and then given the fact that your enum can contain 59 00:03:07,590 --> 00:03:11,280 a particular data value, either an integer or a string 60 00:03:11,280 --> 00:03:15,150 or no value at all, the next question would be, well, 61 00:03:15,150 --> 00:03:16,950 how do you actually put the value 62 00:03:16,950 --> 00:03:19,473 into the enum in the first place, 63 00:03:20,430 --> 00:03:23,313 and how can you get the value back out again of an enum? 64 00:03:24,390 --> 00:03:28,680 So let's say that we have this enum type, a house location, 65 00:03:28,680 --> 00:03:31,260 it could have the state number, 66 00:03:31,260 --> 00:03:34,560 in which case, it has an i32 value in inside it 67 00:03:34,560 --> 00:03:37,440 or it could be in the state name, 68 00:03:37,440 --> 00:03:42,440 you know, the house location name, string, or unknown. 69 00:03:43,200 --> 00:03:46,950 So you could create an enum variable like this. 70 00:03:46,950 --> 00:03:50,010 h1 is an house location variable, 71 00:03:50,010 --> 00:03:52,320 and it is in state number, 72 00:03:52,320 --> 00:03:56,073 and it holds this, saying what variant type it is, 73 00:03:57,660 --> 00:03:59,460 and this is actually kind of putting the value 74 00:03:59,460 --> 00:04:01,950 into it like so. 75 00:04:01,950 --> 00:04:06,950 So if you wanted to imagine what h1 looks like, 76 00:04:07,380 --> 00:04:11,040 h1 is a house location object. 77 00:04:11,040 --> 00:04:14,280 Each enum variable will be the same size 78 00:04:14,280 --> 00:04:17,490 big enough to store the largest type of value, 79 00:04:17,490 --> 00:04:19,710 big enough to store either an integer or a spice. 80 00:04:19,710 --> 00:04:21,960 It's a bit like a union in other languages. 81 00:04:21,960 --> 00:04:25,860 So h1, basically, has state number. 82 00:04:25,860 --> 00:04:29,433 Okay, so that means we know that it contains an i32. 83 00:04:30,960 --> 00:04:34,683 Okay, and it contains, specifically, the value number four. 84 00:04:36,210 --> 00:04:37,043 Okay. 85 00:04:38,010 --> 00:04:42,210 Or you could create another house location variable h2. 86 00:04:42,210 --> 00:04:43,713 Okay, so same size, 87 00:04:44,820 --> 00:04:49,820 h2, but this one holds a name. 88 00:04:50,220 --> 00:04:53,260 So this is like a flag to say it holds a number 89 00:04:54,210 --> 00:04:55,823 or a name, okay? 90 00:04:56,700 --> 00:04:58,590 So I've called it name. 91 00:04:58,590 --> 00:05:00,660 So it is currently in state name. 92 00:05:00,660 --> 00:05:04,440 H2 knows that it holds the a name, 93 00:05:04,440 --> 00:05:09,440 a string, in other words, and that string is cartref, home. 94 00:05:11,610 --> 00:05:15,720 Like that or, possibly, I could create a variant, sorry 95 00:05:15,720 --> 00:05:20,103 I could create an enum variable h3 with state unknown, 96 00:05:21,510 --> 00:05:23,850 in which case, the unknown state 97 00:05:23,850 --> 00:05:26,280 doesn't have any associated value. 98 00:05:26,280 --> 00:05:31,280 So the variant indicates the type of value that it contains, 99 00:05:32,130 --> 00:05:35,490 and then it contains a value of that type. 100 00:05:35,490 --> 00:05:40,490 So this variant would indicate if an enum has that variant, 101 00:05:42,300 --> 00:05:44,313 then you'd know that it has a string. 102 00:05:45,150 --> 00:05:48,030 You can get a string value out of it like so. 103 00:05:48,030 --> 00:05:50,490 So an enum not only tells you what state it is, 104 00:05:50,490 --> 00:05:53,433 but tells you a value associated with that state. 105 00:05:54,930 --> 00:05:59,310 Right, so how would you test if you had a house location, 106 00:05:59,310 --> 00:06:00,840 let's call it hx, 107 00:06:00,840 --> 00:06:02,800 how can you actually get the value out of it? 108 00:06:02,800 --> 00:06:05,250 Well, you need to test its state. 109 00:06:05,250 --> 00:06:08,820 You need to basically say, is it in this state, 110 00:06:08,820 --> 00:06:10,380 in which case, I'll get a number? 111 00:06:10,380 --> 00:06:14,100 Or is in this state, in which case, I'll get a string? 112 00:06:14,100 --> 00:06:15,570 Or is it in this state, 113 00:06:15,570 --> 00:06:17,700 in which case there is no value to get? 114 00:06:17,700 --> 00:06:21,270 So you use a match statement, and it looks like this. 115 00:06:21,270 --> 00:06:24,870 You declare a house location variable, give it some value, 116 00:06:24,870 --> 00:06:29,223 and then you say, if the value is in this state, 117 00:06:30,120 --> 00:06:32,070 what it'll do is it'll say, right, 118 00:06:32,070 --> 00:06:34,410 so h, my house location, 119 00:06:34,410 --> 00:06:38,160 let's say that it is in state number, okay, 120 00:06:38,160 --> 00:06:41,220 which means that it does have a numeric value inside it, 121 00:06:41,220 --> 00:06:42,960 like my house number four. 122 00:06:42,960 --> 00:06:46,770 If my h variable is in this state, 123 00:06:46,770 --> 00:06:50,190 then it'll take the value inside it and put it into here. 124 00:06:50,190 --> 00:06:51,900 It extracts the value into n. 125 00:06:51,900 --> 00:06:54,990 n will be an i32, okay, 126 00:06:54,990 --> 00:06:57,660 because that's what the house number type was. 127 00:06:57,660 --> 00:07:00,180 Alternatively, it could have been the case 128 00:07:00,180 --> 00:07:04,080 that my house location didn't contain a number, 129 00:07:04,080 --> 00:07:07,820 but it contained the name variant, okay? 130 00:07:07,820 --> 00:07:09,870 In which case, the value inside here 131 00:07:09,870 --> 00:07:11,673 will be a string, cartref. 132 00:07:13,770 --> 00:07:17,160 So you say, well, if h currently 133 00:07:17,160 --> 00:07:20,730 has that kind of value inside it, name, yes it does, 134 00:07:20,730 --> 00:07:24,120 then it'll take the value, which is a string, 135 00:07:24,120 --> 00:07:25,530 and assign it into here in, okay, 136 00:07:25,530 --> 00:07:27,600 so S is now gonna be a string, 137 00:07:27,600 --> 00:07:31,680 and then, obviously, if my house location variable h, 138 00:07:31,680 --> 00:07:34,290 if it doesn't have any value at all, 139 00:07:34,290 --> 00:07:38,283 or rather if it has the unknown variant, 140 00:07:39,210 --> 00:07:41,400 okay, so I've created the house location, 141 00:07:41,400 --> 00:07:44,490 and I've given it the value unknown, 142 00:07:44,490 --> 00:07:48,840 then in that case, there is no value associated with it. 143 00:07:48,840 --> 00:07:51,397 We know that it's in state unknown, 144 00:07:51,397 --> 00:07:53,610 but we know that there's no data 145 00:07:53,610 --> 00:07:56,460 associated with that variant, okay? 146 00:07:56,460 --> 00:07:59,550 So it's very easy to create an enum, 147 00:07:59,550 --> 00:08:01,980 give it a value of a certain type, really, 148 00:08:01,980 --> 00:08:04,320 and then extract the value using a match statement, 149 00:08:04,320 --> 00:08:07,350 which is like an if statement, really, in disguise. 150 00:08:07,350 --> 00:08:10,980 Right, so when I need to find an enum with data, 151 00:08:10,980 --> 00:08:15,980 like my enum color, then the size or my enum house location, 152 00:08:17,070 --> 00:08:21,240 should say, an enum variable would be big enough 153 00:08:21,240 --> 00:08:23,490 to store the largest value. 154 00:08:23,490 --> 00:08:25,533 So with my house location, 155 00:08:25,533 --> 00:08:28,743 if the house location had state number, 156 00:08:29,610 --> 00:08:31,713 then it would hold an integer. 157 00:08:33,150 --> 00:08:35,973 If the enum state was name, 158 00:08:37,710 --> 00:08:40,860 then the same variable would have to hold a string. 159 00:08:40,860 --> 00:08:43,740 Okay, so the variable will always be big enough 160 00:08:43,740 --> 00:08:45,810 to store the largest variant. 161 00:08:45,810 --> 00:08:47,190 It could change its value. 162 00:08:47,190 --> 00:08:51,873 So initially, my house location could hold a number. 163 00:08:53,640 --> 00:08:54,750 Okay, like the number four, 164 00:08:54,750 --> 00:08:57,540 and then I could reassign it a value later on, 165 00:08:57,540 --> 00:09:00,690 told maybe I actually give my house a name, 166 00:09:00,690 --> 00:09:02,760 in which case, I would change the value 167 00:09:02,760 --> 00:09:04,770 to be a name with the string. 168 00:09:04,770 --> 00:09:07,860 So the variable itself doesn't change size. 169 00:09:07,860 --> 00:09:12,000 It was always big enough to store the largest variant, 170 00:09:12,000 --> 00:09:14,550 depending on what value you want to put in, okay? 171 00:09:14,550 --> 00:09:17,250 So if you are interested, you can actually find out 172 00:09:17,250 --> 00:09:22,250 the size of the variable using the size of function. 173 00:09:22,620 --> 00:09:24,900 So we've seen this before. 174 00:09:24,900 --> 00:09:27,120 I'm gonna give you a little bit more technical insight 175 00:09:27,120 --> 00:09:29,760 now that we've had a few more discussions. 176 00:09:29,760 --> 00:09:32,820 std is a crate. 177 00:09:32,820 --> 00:09:33,720 It is the... 178 00:09:33,720 --> 00:09:38,103 std is a crate. 179 00:09:40,200 --> 00:09:44,913 It's the standard library in Rust. 180 00:09:46,290 --> 00:09:49,620 Okay, so the entire Rust standard library 181 00:09:49,620 --> 00:09:52,860 is in the std crate, which is kind of like 182 00:09:52,860 --> 00:09:54,591 it companies your application. 183 00:09:54,591 --> 00:09:59,591 In the std crate, it defines lots and lots of modules. 184 00:10:00,780 --> 00:10:05,555 So mem is a module like a namespace, okay? 185 00:10:05,555 --> 00:10:09,810 So in the std crate mem is a module, 186 00:10:09,810 --> 00:10:14,550 a namespace that defines related things, memory related. 187 00:10:14,550 --> 00:10:17,640 In the mem module, 188 00:10:17,640 --> 00:10:21,930 there is a function called size of, the size of function 189 00:10:21,930 --> 00:10:25,740 in the mem module in the std crate, 190 00:10:25,740 --> 00:10:28,560 and size of is a generic function. 191 00:10:28,560 --> 00:10:29,760 When you call the generic, 192 00:10:29,760 --> 00:10:31,260 when you call the size of function, 193 00:10:31,260 --> 00:10:33,570 you need to give it a type name. 194 00:10:33,570 --> 00:10:35,430 and then it'll tell you how big it is. 195 00:10:35,430 --> 00:10:38,820 So in Rust, when you call a generic function, 196 00:10:38,820 --> 00:10:42,210 you have double colon and then you have the type name 197 00:10:42,210 --> 00:10:44,430 that you wanna specify, okay? 198 00:10:44,430 --> 00:10:47,100 So that's how you can call the generic function. 199 00:10:47,100 --> 00:10:49,500 You pass in the type name, house location, 200 00:10:49,500 --> 00:10:52,410 and it'll tell you how many bites is house location. 201 00:10:52,410 --> 00:10:53,910 Just a word of caution, 202 00:10:53,910 --> 00:10:56,910 if you're coming from other languages, most other languages, 203 00:10:56,910 --> 00:10:59,940 when you are passing or calling generic functions, 204 00:10:59,940 --> 00:11:02,190 and you're telling it the type involved, 205 00:11:02,190 --> 00:11:05,970 in most other languages, you don't have a colon colon here. 206 00:11:05,970 --> 00:11:08,940 You would just call the function name, angle brackets, 207 00:11:08,940 --> 00:11:11,100 type name, and then the function name, 208 00:11:11,100 --> 00:11:13,170 but in Rust, it's different. 209 00:11:13,170 --> 00:11:14,970 You have the name of the generic function, 210 00:11:14,970 --> 00:11:17,490 and then you have another set of colons here, 211 00:11:17,490 --> 00:11:20,070 and then the type name inside angle brackets, 212 00:11:20,070 --> 00:11:22,980 and it'll tell you how big house location is. 213 00:11:22,980 --> 00:11:26,035 For us, house location will be the larger 214 00:11:26,035 --> 00:11:29,340 of an integer 32 and a string. 215 00:11:29,340 --> 00:11:31,110 So basically, it's gonna be the size of a string 216 00:11:31,110 --> 00:11:33,060 because that's the larger type. 217 00:11:33,060 --> 00:11:35,070 So time for an example, let's go back 218 00:11:35,070 --> 00:11:38,700 into the project lesson04_enums, 219 00:11:38,700 --> 00:11:41,250 and we go to look at mytypes.rs, 220 00:11:41,250 --> 00:11:45,270 which defines the house location enum, and then in main.rs, 221 00:11:45,270 --> 00:11:46,620 we're gonna have a look at this function here, 222 00:11:46,620 --> 00:11:47,703 demo_enum_with_data. 223 00:11:48,653 --> 00:11:50,610 We'll go through the code, 224 00:11:50,610 --> 00:11:54,210 and then we'll run it, and see what it says. 225 00:11:54,210 --> 00:11:56,883 Okay, so here's my demo project. 226 00:11:57,750 --> 00:12:01,440 I've reverted all my code to as it was originally. 227 00:12:01,440 --> 00:12:06,440 mytypes is there, and mytypes for demo purposes is here. 228 00:12:09,840 --> 00:12:12,180 Okay, so we could use either of those. 229 00:12:12,180 --> 00:12:16,380 I think I'm going to use mytypes for demo purposes. 230 00:12:16,380 --> 00:12:17,970 It's got my house location, 231 00:12:17,970 --> 00:12:22,830 and it's allowing me to have unused variance, okay? 232 00:12:22,830 --> 00:12:24,540 And my main code, I'm using, 233 00:12:24,540 --> 00:12:26,850 I'm not using the original mytypes. 234 00:12:26,850 --> 00:12:29,220 I'm using the types for demo purposes 235 00:12:29,220 --> 00:12:31,020 so I don't get any warnings. 236 00:12:31,020 --> 00:12:34,050 I guess I could have had a crate level macro to say 237 00:12:34,050 --> 00:12:36,963 or attribute to say allow dead code at the top of my code. 238 00:12:37,890 --> 00:12:39,276 That would also have worked. 239 00:12:39,276 --> 00:12:42,930 Okay, so that's the function that we're gonna call 240 00:12:42,930 --> 00:12:47,730 demo_enum_with_data, and here it is, 241 00:12:47,730 --> 00:12:52,170 and I create a house location variable, 242 00:12:52,170 --> 00:12:54,659 and I say that it's a house location, 243 00:12:54,659 --> 00:12:59,659 and I give it the number variant, 244 00:12:59,760 --> 00:13:03,000 and in the number variant, remember, 245 00:13:03,000 --> 00:13:08,000 that means you've gotta then give it an integer 32, an i32. 246 00:13:08,070 --> 00:13:09,510 So I give it the number four, 247 00:13:09,510 --> 00:13:10,800 that's our house location. 248 00:13:10,800 --> 00:13:15,630 Here, I didn't need to actually give it a data type. 249 00:13:15,630 --> 00:13:17,520 I could have just written it like that, 250 00:13:17,520 --> 00:13:18,870 and that would've also been fine. 251 00:13:18,870 --> 00:13:21,150 It knows that it's house location. 252 00:13:21,150 --> 00:13:24,780 So then, I test my variable, 253 00:13:24,780 --> 00:13:26,070 and I, basically, test the variant. 254 00:13:26,070 --> 00:13:27,480 The variant is like a discriminated 255 00:13:27,480 --> 00:13:29,040 to say what state are we currently in? 256 00:13:29,040 --> 00:13:30,840 Oh, grab that value then. 257 00:13:30,840 --> 00:13:33,120 If you're currently in the number state, 258 00:13:33,120 --> 00:13:36,510 then grab the value out of it into this variable. 259 00:13:36,510 --> 00:13:37,920 So this variable gets created. 260 00:13:37,920 --> 00:13:41,190 n gets created here as an i32. 261 00:13:41,190 --> 00:13:43,290 You live in house number four. 262 00:13:43,290 --> 00:13:45,490 That's where it's gonna print at the moment. 263 00:13:46,530 --> 00:13:51,530 Let's run the application in a terminal window, cargo run. 264 00:13:57,540 --> 00:13:59,970 Okay, so you live in house number four. 265 00:13:59,970 --> 00:14:03,450 Oh, and at the end, it says, by the way, 266 00:14:03,450 --> 00:14:06,540 the size of a house location variable is, 267 00:14:06,540 --> 00:14:09,360 and I've got the size of function here, 268 00:14:09,360 --> 00:14:11,997 and it is 32 bytes, okay? 269 00:14:11,997 --> 00:14:14,853 So, basically, that's our biggest string object is. 270 00:14:16,110 --> 00:14:19,740 Right, what if I change my code here 271 00:14:19,740 --> 00:14:23,400 so that instead of knowing the house location as a number, 272 00:14:23,400 --> 00:14:25,293 I know it as a name, cartref. 273 00:14:28,560 --> 00:14:31,544 In Welsh, an F is pronounced as a V, cartref, 274 00:14:31,544 --> 00:14:35,010 a hard V, cartref, like so. 275 00:14:35,010 --> 00:14:39,210 So now, it's going to match this branch or this arm, 276 00:14:39,210 --> 00:14:43,110 and it'll say you live in a house named cartref. 277 00:14:43,110 --> 00:14:45,210 Thank you, yes, well, not really, 278 00:14:45,210 --> 00:14:46,760 but that's what it's gonna say. 279 00:14:48,660 --> 00:14:50,970 Oh, right, there's a thing here. 280 00:14:50,970 --> 00:14:52,770 I'll get onto this later. 281 00:14:52,770 --> 00:14:54,270 When you have string literals, 282 00:14:54,270 --> 00:14:57,270 you have to write it this way, string::from. 283 00:14:57,270 --> 00:15:00,690 I don't wanna get involved too much about that just yet. 284 00:15:00,690 --> 00:15:03,780 We need to discuss what that actually means later. 285 00:15:03,780 --> 00:15:05,910 So let's just brush that one under the carpet for now, 286 00:15:05,910 --> 00:15:09,840 and just we will come back and look at that later on. 287 00:15:09,840 --> 00:15:13,653 So you live in a house named cartref. 288 00:15:14,520 --> 00:15:16,200 Okay, very good, 289 00:15:16,200 --> 00:15:19,770 and then we'll say let's change one final type to say 290 00:15:19,770 --> 00:15:21,269 we live in a house. 291 00:15:21,269 --> 00:15:24,240 The house location is unknown, okay? 292 00:15:24,240 --> 00:15:26,490 I don't know where you live, basically. 293 00:15:26,490 --> 00:15:28,380 So it'll come back. 294 00:15:28,380 --> 00:15:30,963 Your house location is unknown. 295 00:15:30,963 --> 00:15:32,790 Your house location is unknown, 296 00:15:32,790 --> 00:15:37,200 but in every case, the variable was still the same size 297 00:15:37,200 --> 00:15:38,640 because maybe what I could have done 298 00:15:38,640 --> 00:15:40,470 is this variable was multiple. 299 00:15:40,470 --> 00:15:43,440 Maybe, initially, it was unknown, 300 00:15:43,440 --> 00:15:45,900 but then later on, I could reassign it, couldn't I? 301 00:15:45,900 --> 00:15:47,909 I could say let's reassign it to be 302 00:15:47,909 --> 00:15:52,587 a HouseLocation::Number(4). 303 00:15:56,610 --> 00:16:01,560 Okay, so it was unknown, and, now, it's the number four. 304 00:16:01,560 --> 00:16:04,560 So basically, the variable doesn't change size. 305 00:16:04,560 --> 00:16:07,560 It's always big enough to hold the largest possible type 306 00:16:07,560 --> 00:16:10,350 just in case you give it a different variable. 307 00:16:10,350 --> 00:16:12,993 So now, it'll still be 32 bytes. 308 00:16:15,690 --> 00:16:16,523 There we go. 309 00:16:18,120 --> 00:16:19,470 Right, so there we are. 310 00:16:19,470 --> 00:16:21,840 That's the end of this section. 311 00:16:21,840 --> 00:16:24,990 Having an enum that not only tells you what state it is 312 00:16:24,990 --> 00:16:27,330 but also gives you a value associated 313 00:16:27,330 --> 00:16:29,070 with the current state. 314 00:16:29,070 --> 00:16:32,940 This is an extremely powerful mechanism in Rust, 315 00:16:32,940 --> 00:16:36,390 and for the last two sections of the lesson, 316 00:16:36,390 --> 00:16:39,570 we are going to look at a couple of standard enum types 317 00:16:39,570 --> 00:16:43,080 in Rust, option and result, which make use 318 00:16:43,080 --> 00:16:46,383 of this kind of data bearing mechanism for enums.