From 5ab6fae9e912eb2e5762b92e8b646ff0d9a13755 Mon Sep 17 00:00:00 2001 From: Nicole L Date: Thu, 27 Feb 2025 12:33:06 -0800 Subject: [PATCH] Suppress warnings for elevator exercise (#2668) --- src/user-defined-types/exercise.md | 10 ++++++++++ src/user-defined-types/exercise.rs | 4 ++-- 2 files changed, 12 insertions(+), 2 deletions(-) diff --git a/src/user-defined-types/exercise.md b/src/user-defined-types/exercise.md index 4377ceb3..524d258b 100644 --- a/src/user-defined-types/exercise.md +++ b/src/user-defined-types/exercise.md @@ -41,3 +41,13 @@ out of these structures. {{#include exercise.rs:main}} ``` + +
+ +- If students ask about `#![allow(dead_code)]` at the top of the exercise, it's + necessary because the only thing we do with the `Event` type is print it out. + Due to a nuance of how the compiler checks for dead code this causes it to + think that the code is unused. They can ignore it for the purpose of this + exercise. + +
diff --git a/src/user-defined-types/exercise.rs b/src/user-defined-types/exercise.rs index d8041993..6aced372 100644 --- a/src/user-defined-types/exercise.rs +++ b/src/user-defined-types/exercise.rs @@ -12,10 +12,10 @@ // See the License for the specific language governing permissions and // limitations under the License. -#![allow(dead_code)] - // ANCHOR: solution // ANCHOR: event +#![allow(dead_code)] + #[derive(Debug)] /// An event in the elevator system that the controller must react to. enum Event {