April 2026
Intermediate
631 pages
16h 20m
English
This section provides the code solutions for the practice exercises in Section 6.7. The code is largely self-explanatory; however, we have included comments and additional explanations wherever necessary to enhance understanding.
Fixing visibility issues in nested modules
mod m1 { struct A { d: m2::D, } mod m2 { pub enum D { // Child module items are not visible to the // parent module B, C, } }}fn main(){}
Resolving module visibility and path issues
mod m1 { struct A { d: m2::D, } pub mod m2 { /* Public items of a private child module, are only accessible by the parent. We need to make the child module m2 pub, so that its public items can be used outside the parent module.*/ pub enum D { B, C, } }}mod m3 { struct
Read now
Unlock full access