mirror of
https://github.com/rust-lang/rustlings.git
synced 2026-05-18 11:18:44 +00:00
docs(exercises): clarify if3 requires uniform branch types
Closes #2211 Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
parent
db3f332507
commit
6b7f4955bb
@ -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" {
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user