[英]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.