soc.me · Nov 7, 2022
Language Design: Unified Condition Expressions – Comparison with Rust
0Sign in to vote or save
This page cannot be shown here. You can still read it on the original site — the toolbar below keeps your place in the directory.
simple if expression if x == 1.0 { "a" } else { "z" } This translates straight-forward to Rust: if x == 1.0 { "a" } else { "z" } multiple cases, equality relation if x ... == 1.0 { "a" } ... == 2.0 { "b" } else { "z" } In Rust, using match is idiomatic: match x { 1.0 => "a" , 2.0 => "b" , _ => "z" } multiple cases, any other relation if x ... == 1.0 { "a" } ... != 2.0 { "b" } else { "z" } Rust…
Read on /languages/unified-condition-expressions-comparison.html ↗
Comments
Nothing yet. Say the first thing.
Sign in to join the conversation.