Fixed typo predule to prelude.

pull/122/head
Hung Hoang 3 years ago committed by GitHub
parent 1980638e43
commit e8a1afaed8
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

@ -7996,7 +7996,7 @@ fn give_direction(direction: &MapDirection) {
}
```
We've seen that `::*` means "import everything after the ::". In our case, that means `North`, `NorthEast`...and all the way to `NorthWest`. When you import other people's code you can do that too, but if the code is very large you might have problems. What if it has some items that are the same as your code? So it's usually best to not use `::*` all the time unless you're sure. A lot of times you see a section called `prelude` in other people's code with all the main items you probably need. So then you will usually use it like this: `name::predule::*`. We will talk about this more in the sections for `modules` and `crates`.
We've seen that `::*` means "import everything after the ::". In our case, that means `North`, `NorthEast`...and all the way to `NorthWest`. When you import other people's code you can do that too, but if the code is very large you might have problems. What if it has some items that are the same as your code? So it's usually best to not use `::*` all the time unless you're sure. A lot of times you see a section called `prelude` in other people's code with all the main items you probably need. So then you will usually use it like this: `name::prelude::*`. We will talk about this more in the sections for `modules` and `crates`.
You can also use `as` to change the name. For example, maybe you are using someone else's code and you can't change the names in an enum:

Loading…
Cancel
Save