2019-07-27 00:54:25 +03:00
|
|
|
// run-pass
|
|
|
|
|
2018-09-14 12:20:28 +02:00
|
|
|
#![allow(non_camel_case_types)]
|
|
|
|
#![allow(dead_code)]
|
2015-01-20 15:45:07 -08:00
|
|
|
#[derive(Clone, Debug)]
|
2012-01-19 16:10:31 -08:00
|
|
|
enum foo {
|
2015-03-25 17:06:52 -07:00
|
|
|
a(usize),
|
2014-05-22 16:57:53 -07:00
|
|
|
b(String),
|
2012-01-15 21:42:10 -08:00
|
|
|
}
|
|
|
|
|
2015-01-20 15:45:07 -08:00
|
|
|
fn check_log<T: std::fmt::Debug>(exp: String, v: T) {
|
2014-12-20 00:09:35 -08:00
|
|
|
assert_eq!(exp, format!("{:?}", v));
|
2012-01-15 21:42:10 -08:00
|
|
|
}
|
|
|
|
|
2013-02-01 19:43:17 -08:00
|
|
|
pub fn main() {
|
2015-01-20 15:45:07 -08:00
|
|
|
let mut x = Some(foo::a(22));
|
|
|
|
let exp = "Some(a(22))".to_string();
|
2014-12-20 00:09:35 -08:00
|
|
|
let act = format!("{:?}", x);
|
2014-03-18 21:31:40 -07:00
|
|
|
assert_eq!(act, exp);
|
|
|
|
check_log(exp, x);
|
|
|
|
|
|
|
|
x = None;
|
2014-05-25 03:17:19 -07:00
|
|
|
let exp = "None".to_string();
|
2014-12-20 00:09:35 -08:00
|
|
|
let act = format!("{:?}", x);
|
2014-03-18 21:31:40 -07:00
|
|
|
assert_eq!(act, exp);
|
2012-01-15 21:42:10 -08:00
|
|
|
check_log(exp, x);
|
|
|
|
}
|