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

Upvotes: 18

Views: 13081

Answers (1)

malbarbo
malbarbo

Reputation: 11177

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.

Upvotes: 37

Related Questions