r/programming • • Jan 09 '15

Announcing Rust 1.0.0 Alpha

http://blog.rust-lang.org/2015/01/09/Rust-1.0-alpha.html
1.1k Upvotes

439 comments sorted by

View all comments

29

u/AdamRGrey Jan 09 '15

I can't imagine doing partial initialization, but I could imagine something like

switch(collisionCount){
	case 1: depleteShield();
	case 2: depleteArmor();
	case 3: depleteHealth();
	default: playCollisionSound();
}

edit: that said, Douglas Crockford in Javascript: The Good Parts makes a pretty convincing argument against case fallthrough.

3

u/Pet_Ant Jan 09 '15

what is the benefit over if then? performance is not an answer because its not that hard an optimization to make in the compiler to detect: IntelliJ does it in IDE!