2015-08-25 14:46:58 -05:00
|
|
|
// Format if-else expressions on a single line, when possible.
|
|
|
|
|
|
|
|
fn main() {
|
|
|
|
let a = if 1 > 2 { unreachable!() } else { 10 };
|
|
|
|
|
|
|
|
let a = if x {
|
|
|
|
1
|
2015-08-25 15:07:02 -05:00
|
|
|
} else if y {
|
|
|
|
2
|
|
|
|
} else {
|
|
|
|
3
|
|
|
|
};
|
2015-08-25 14:46:58 -05:00
|
|
|
|
|
|
|
let b = if cond() {
|
|
|
|
5
|
|
|
|
} else {
|
|
|
|
// Brief comment.
|
|
|
|
10
|
|
|
|
};
|
|
|
|
|
|
|
|
let c = if cond() {
|
|
|
|
statement();
|
|
|
|
|
|
|
|
5
|
|
|
|
} else {
|
|
|
|
10
|
|
|
|
};
|
|
|
|
|
2017-11-24 01:17:06 -06:00
|
|
|
let d = if let Some(val) = turbo {
|
|
|
|
"cool"
|
|
|
|
} else {
|
|
|
|
"beans"
|
|
|
|
};
|
2015-08-25 15:07:02 -05:00
|
|
|
|
2015-08-25 14:46:58 -05:00
|
|
|
if cond() {
|
|
|
|
statement();
|
|
|
|
} else {
|
|
|
|
other_statement();
|
|
|
|
}
|
|
|
|
|
|
|
|
if true {
|
|
|
|
do_something()
|
|
|
|
}
|
|
|
|
|
|
|
|
let x = if veeeeeeeeery_loooooong_condition() {
|
2016-05-12 14:50:43 -05:00
|
|
|
aaaaaaaaaaaaaaaaaaaaaaaaaaaaaa
|
2015-08-25 14:46:58 -05:00
|
|
|
} else {
|
|
|
|
bbbbbbbbbb
|
|
|
|
};
|
|
|
|
|
2017-11-24 01:17:06 -06:00
|
|
|
let x = if veeeeeeeeery_loooooong_condition() {
|
|
|
|
aaaaaaaaaaaaaaaaaaaaaaaaa
|
|
|
|
} else {
|
|
|
|
bbbbbbbbbb
|
|
|
|
};
|
2015-08-25 14:46:58 -05:00
|
|
|
|
|
|
|
funk(if test() { 1 } else { 2 }, arg2);
|
|
|
|
}
|