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