1 00:00:05,820 --> 00:00:12,120 As you begin to write larger and more complex programs, it becomes important to organize your code. 2 00:00:12,600 --> 00:00:19,740 There are a number of features Rust has to help us manage our codes organization and they are packages, 3 00:00:19,740 --> 00:00:22,560 crates, modules and paths. 4 00:00:23,430 --> 00:00:27,570 Packages allow us to build, test and share crates. 5 00:00:28,200 --> 00:00:34,140 Crates are a trio of modules that produces a library or an executable. 6 00:00:35,090 --> 00:00:36,050 Modules. 7 00:00:36,050 --> 00:00:38,120 Let us control the organisation. 8 00:00:38,120 --> 00:00:40,520 Scope and privacy of paths. 9 00:00:40,760 --> 00:00:48,800 And lastly, pass road or a way of naming an item such as a shrunk function or module. 10 00:00:49,220 --> 00:00:50,750 So what does a package? 11 00:00:50,780 --> 00:00:55,250 A package is one or more crates that is going to provide functionality. 12 00:00:55,430 --> 00:01:02,900 Inside a package is a cargo terminal file with instructions on how to build those crates, which every 13 00:01:02,900 --> 00:01:10,400 time we have used cargo new, we have been provided with a cargo Thomas file, which is what I have 14 00:01:10,400 --> 00:01:11,600 displayed here. 15 00:01:11,600 --> 00:01:18,530 And if we had any dependencies in our code, we would be able to see them listed here. 16 00:01:20,240 --> 00:01:21,930 So what does cargo new? 17 00:01:21,950 --> 00:01:25,670 So what cargo new does is creates a new package. 18 00:01:26,030 --> 00:01:33,050 And then inside our directory, we have a cargo file here and also a source directory. 19 00:01:33,140 --> 00:01:38,660 This directory isn't mentioned in the cargo file because cargo follows a convention. 20 00:01:38,660 --> 00:01:48,770 That source slash main dot RS is the crate root of a binary crate and source slash lib rs, which we 21 00:01:48,770 --> 00:01:52,790 will see in the next lecture is going to define a library crate. 22 00:01:53,450 --> 00:01:56,990 The crate allows us to keep related functionality together. 23 00:01:56,990 --> 00:02:02,360 That way is easy for us to use in different projects when we reference the Crates name. 24 00:02:02,930 --> 00:02:07,850 So now let's take a look at modules and let's build out our first library.