2019-11-04 00:00:00 +00:00
|
|
|
// check-pass
|
2018-09-25 21:51:35 +00:00
|
|
|
#![allow(dead_code)]
|
|
|
|
#![allow(unused_mut)]
|
2013-09-02 13:33:17 +00:00
|
|
|
/*
|
|
|
|
# if b { x } else { y } requires identical types for x and y
|
|
|
|
*/
|
|
|
|
|
|
|
|
fn print1(b: bool, s1: &str, s2: &str) {
|
2014-01-09 10:06:55 +00:00
|
|
|
println!("{}", if b { s1 } else { s2 });
|
2013-09-02 13:33:17 +00:00
|
|
|
}
|
|
|
|
fn print2<'a, 'b>(b: bool, s1: &'a str, s2: &'b str) {
|
2014-01-09 10:06:55 +00:00
|
|
|
println!("{}", if b { s1 } else { s2 });
|
2013-09-02 13:33:17 +00:00
|
|
|
}
|
|
|
|
fn print3(b: bool, s1: &str, s2: &str) {
|
|
|
|
let mut s: &str;
|
|
|
|
if b { s = s1; } else { s = s2; }
|
2014-01-09 10:06:55 +00:00
|
|
|
println!("{}", s);
|
2013-09-02 13:33:17 +00:00
|
|
|
}
|
|
|
|
fn print4<'a, 'b>(b: bool, s1: &'a str, s2: &'b str) {
|
|
|
|
let mut s: &str;
|
|
|
|
if b { s = s1; } else { s = s2; }
|
2014-01-09 10:06:55 +00:00
|
|
|
println!("{}", s);
|
2013-09-02 13:33:17 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
pub fn main() {}
|