From 6b7f4955bb16c26e5835d836b3d1f60c443aacb1 Mon Sep 17 00:00:00 2001 From: wuyangfan <1102042793@qq.com> Date: Sun, 17 May 2026 14:08:22 +0800 Subject: [PATCH] docs(exercises): clarify if3 requires uniform branch types Closes #2211 Co-authored-by: Cursor --- exercises/03_if/if3.rs | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/exercises/03_if/if3.rs b/exercises/03_if/if3.rs index 89164eb2..67d1bc43 100644 --- a/exercises/03_if/if3.rs +++ b/exercises/03_if/if3.rs @@ -1,5 +1,10 @@ fn animal_habitat(animal: &str) -> &str { // TODO: Fix the compiler error in the statement below. + // + // Hint: every `if` / `else if` / `else` branch must produce the same type. + // A floating-point literal, a string, and integers cannot be mixed in one chain. + // For unknown animals, use another integer identifier (for example `4`) instead of + // a string, then keep the habitat checks below unchanged. let identifier = if animal == "crab" { 1 } else if animal == "gopher" {