Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

What does "the trait bound std::fmt::Display is not satisfied" mean?

Tags:

rust

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

like image 787
Дмитрий Комар Avatar asked Jul 07 '16 19:07

Дмитрий Комар


1 Answers

println! is a macro to do formatted output. {} is used to print a value that implements the Display trait. The error is saying that Timespec does not implement the Display trait, so it cannot be used with {}.

You can use {:?} instead of {}. {:?} is used to print a value that implements Debug trait and Timespec implements it.

Consider reading the fmt module documentation, it explain this in detail.

like image 189
malbarbo Avatar answered Oct 11 '22 11:10

malbarbo