简体   繁体   English

“特质绑定std :: fmt :: Display不满意”是什么意思?

[英]What does “the trait bound std::fmt::Display is not satisfied” mean?

My code: 我的代码:

extern crate time;

fn main() {
    println!("{}", time::get_time());
}

My error is: 我的错误是:

Error 'the trait bound time::Timespec: std::fmt::Display is not satisfied

println! is a macro to do formatted output. 是一个做格式化输出的宏。 {} is used to print a value that implements the Display trait. {}用于打印实现Display trait的值。 The error is saying that Timespec does not implement the Display trait, so it cannot be used with {} . 错误是说Timespec没有实现Display特性,所以它不能与{}一起使用。

You can use {:?} instead of {} . 您可以使用{:?}而不是{} {:?} is used to print a value that implements Debug trait and Timespec implements it. {:?}用于打印实现Debug特性的值, Timespec实现它。

Consider reading the fmt module documentation, it explain this in detail. 考虑阅读fmt模块文档,它会详细解释这一点。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM