Debug for libc structs

Hi there! I have some struct that have Debug formating:

#[derive(Debug)]
struct ... {
...,
sembuf: libc::sembuf,
}

But i got an error:

sembuf cannot be formatted using {:?} because it doesn't implement Debug.

If i implement Debug for libc::sembuf i got another error:

impl doesn't use only types from inside the current crate

Simple implematation:

impl fmt::Debug for libc::sembuf {
    fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
        write!(f, {}", self.sem_num)
    }
}

Please, help. How can i resolve this problem? Because I need debug information for a number of structures that borrow each other in fields.

It is not possible to implement a 3rd-party trait for a 3rd-party type (because then either one could have a conflicting implementation with yours).

Why don't you implement Debug directly on your own struct? Then you can control how to format each individual field, even when some of them isn't Debug.

I didn't think of it before, thanks!