April 2026
Intermediate
631 pages
16h 20m
English
This section provides the code solutions for the practice exercises in Section 7.5. The code is largely self-explanatory; however, we have included comments and additional explanations wherever necessary to enhance understanding.
Handling struct and enum visibility in Rust modules
mod m1 { struct A { d: m2::D, } mod m2 { pub enum D { // Child module items are not visible to parent module // by default B, C, } }}fn main(){}
Resolving module imports and visibility in Rust
mod m1 { struct A { d: m2::D, } pub mod m2 { /* Public items of a private child module are only accessible by parent module. 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,
Read now
Unlock full access