2016-08-19 41 views

回答

12

什么你要找的是Debug格式化:

let mut hash = HashMap::new(); 
hash.insert("Daniel", "798-1364"); 
println!("{:?}", hash); 

这应该打印:

{"Daniel": "798-1364"} 
+1

对于自定义一个严格的,你需要用#来装饰他们派生(Debug)特性。 http://rustbyexample.com/trait/derive.html – RandomInsano

相关问题