April 2026
Intermediate
631 pages
16h 20m
English
In this section, we’ll provide some practice questions to help reinforce your learning. The exercise questions cover almost all the concepts introduced in the chapter. Solutions to each exercise will follow in Section 7.6.
Handling struct and enum visibility in Rust modulesThe following code provided defines two modules, m1 and m2, with a struct A that contains a field of type m2::D. However, the code fails to compile due to visibility issues. The struct A is trying to access the enum D from the inner module m2, but D is not publicly accessible outside of m2. Your task is to fix the visibility of the enum D and any other necessary components so that the code compiles successfully.
mod m1 { struct A { d: m2::D, }
Read now
Unlock full access