Skip to content

Commit 5ab6fae

Browse files
authored
Suppress warnings for elevator exercise (#2668)
1 parent 8b04a6d commit 5ab6fae

File tree

2 files changed

+12
-2
lines changed

2 files changed

+12
-2
lines changed

src/user-defined-types/exercise.md

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -41,3 +41,13 @@ out of these structures.
4141
4242
{{#include exercise.rs:main}}
4343
```
44+
45+
<details>
46+
47+
- If students ask about `#![allow(dead_code)]` at the top of the exercise, it's
48+
necessary because the only thing we do with the `Event` type is print it out.
49+
Due to a nuance of how the compiler checks for dead code this causes it to
50+
think that the code is unused. They can ignore it for the purpose of this
51+
exercise.
52+
53+
</details>

src/user-defined-types/exercise.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -12,10 +12,10 @@
1212
// See the License for the specific language governing permissions and
1313
// limitations under the License.
1414

15-
#![allow(dead_code)]
16-
1715
// ANCHOR: solution
1816
// ANCHOR: event
17+
#![allow(dead_code)]
18+
1919
#[derive(Debug)]
2020
/// An event in the elevator system that the controller must react to.
2121
enum Event {

0 commit comments

Comments
 (0)