Skip to content
Free public beta until December 4, 2026: every course is open, no card needed. After that, the first chapter of each course stays free and full access is a one-time $39 ($19 for up to 100 founding members chosen for helpful feedback). Your progress is kept. How the beta works

if let

Running code only if a value matches one pattern.

if let PATTERN = expr runs its block when the pattern matches; let chains join several conditions with &&.

Examples

  • if let Some(first) = names.first() { println!("{first}"); } runs only when the list is not empty.

  • In edition 2024, if let Some(n) = age && n >= 18 { ... } joins a pattern and a condition with &&.

Read the full section →