diff --git a/src/pattern-matching/let-control-flow/if-let.md b/src/pattern-matching/let-control-flow/if-let.md index 2f5717f2..d9257069 100644 --- a/src/pattern-matching/let-control-flow/if-let.md +++ b/src/pattern-matching/let-control-flow/if-let.md @@ -8,7 +8,9 @@ lets you execute different code depending on whether a value matches a pattern: use std::time::Duration; fn sleep_for(secs: f32) { - if let Ok(duration) = Duration::try_from_secs_f32(secs) { + let result = Duration::try_from_secs_f32(secs); + + if let Ok(duration) = result { std::thread::sleep(duration); println!("slept for {duration:?}"); }