2014-02-07 19:08:32 +00:00
|
|
|
// Copyright 2012-2014 The Rust Project Developers. See the COPYRIGHT
|
2012-12-11 01:32:48 +00:00
|
|
|
// file at the top-level directory of this distribution and at
|
|
|
|
// http://rust-lang.org/COPYRIGHT.
|
|
|
|
//
|
|
|
|
// Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or
|
|
|
|
// http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
|
|
|
|
// <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your
|
|
|
|
// option. This file may not be copied, modified, or distributed
|
|
|
|
// except according to those terms.
|
|
|
|
|
2014-12-31 04:32:49 +00:00
|
|
|
#[derive(Clone, Show)]
|
2012-01-20 00:10:31 +00:00
|
|
|
enum foo {
|
2012-01-20 02:31:08 +00:00
|
|
|
a(uint),
|
2014-05-22 23:57:53 +00:00
|
|
|
b(String),
|
2012-01-16 05:42:10 +00:00
|
|
|
}
|
|
|
|
|
2014-10-15 01:07:11 +00:00
|
|
|
fn check_log<T: std::fmt::Show>(exp: String, v: T) {
|
|
|
|
assert_eq!(exp, format!("{}", v));
|
2012-01-16 05:42:10 +00:00
|
|
|
}
|
|
|
|
|
2013-02-02 03:43:17 +00:00
|
|
|
pub fn main() {
|
2014-11-06 08:05:53 +00:00
|
|
|
let mut x = Some(foo::a(22u));
|
2014-10-15 01:07:11 +00:00
|
|
|
let exp = "Some(a(22))".to_string();
|
|
|
|
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-10-15 01:07:11 +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);
|
|
|
|
}
|