fnmain(){letn=11;letx=matchn{10=>"unless case 1".to_string(),// Match several values11=>"unless case 2".to_string(),// Match an inclusive range_=>"normal case".to_string(),};println!("{}",x);}
Great, but disagree.
Usually, your "normal case" is the "fallback" method in the control statement, because the else statement is optional and not necessary.
Your normal case is unnatural, because:
you always expect a "normal" way
and when not run the normal way? you may need to check all condition
so you first need to skip the normal way and scroll down to all other condition
The try/catch "normal case" is different. In try/catch you will try to do something and if something wrong you create a fallback.
but this is only my opinion :D
For further actions, you may consider blocking this person and/or reporting abuse
We're a place where coders share, stay up-to-date and grow their careers.
Ok, but why better it's than the pattern matching?
doc.rust-lang.org/book/ch18-03-pat...
So your example like this:
The point is to promote the normal case to the top. In your code the normal case is at the bottom.
The merit of promoting the normal case to the top is it is more natural to read and write. It's a very subtle and subjective merit.
Great, but disagree.
Usually, your "normal case" is the "fallback" method in the control statement, because the else statement is optional and not necessary.
Your normal case is unnatural, because:
The try/catch "normal case" is different. In try/catch you will try to do something and if something wrong you create a fallback.
but this is only my opinion :D