June 2021
Beginner
344 pages
8h 9m
English
Prefixing every map access with map:: or crate::map:: is unwieldy and will get more cumbersome as you add more modules. When you access a Rust library, it’s common for the library author to have placed everything you need in a convenient prelude. You used bracket-lib’s prelude in Hello, Bracket Terminal. You can simplify module access by making your own prelude to export common functionality to the rest of the program. Add the following to your main.rs file:
| ① | mod map; |
| | |
| ② | mod prelude { |
| ③ | pub use bracket_lib::prelude::*; |
| ④ | pub const SCREEN_WIDTH: i32 = 80; |
| | pub const SCREEN_HEIGHT: i32 = 50; |
| ⑤ | pub use crate::map |
Read now
Unlock full access