Need Assistance?

support@tutorialshub.in

Functions & Control Flow

if / else Expressions in Rust

ADVERTISEMENT
Rust Free Lesson
5 min read
ADVERTISEMENT

Conditions in Rust don't need parentheses around them, and they must evaluate strictly to a bool. Because if is an expression, you can assign its result directly to a let variable (replacing the ternary operator from other languages).

ADVERTISEMENT
Hi, I'm Tuby! Here to help you