I'm using the texture-synthesis crate. I'm creating a structure RenderSettings that I'm going to feed into some of this crate's functions:
texture-synthesis = "0.8.0"
use texture_synthesis as ts;
#[derive(Debug, Clone, Copy)]
pub struct RenderSettings{
seed: u64,
tiling_mode: bool,
nearest_neighbors: u32,
output_size: ts::Dims, //throws error
}
However this gives me the error:
`texture_synthesis::Dims` doesn't implement `std::fmt::Debug`
`texture_synthesis::Dims` cannot be formatted using `{:?}` because it doesn't implement `std::fmt::Debug`
I see in the source code this definition of the Dims structure, which seems to implement Debug:
#[derive(Copy, Clone)]
#[cfg_attr(test, derive(Debug, PartialEq))]
pub struct Dims {
pub width: u32,
pub height: u32,
}
I'm imagining my problem has something to do with #[cfg_attr(test, derive(Debug, PartialEq))]. I'm not really sure what this statement means, but it seems to suggest that I can use Debug somehow with this struct. So how can I fix this error?
#[cfg_attr(test, derive(Debug, PartialEq))]means thatDebugandPartialEqwill only be derived when it's intestmode (a.k.a you're runningcargo test). I don't know why the crate authors decided to do this, but you could always make a newtype (tuple struct with one element) and make your ownDebugon that sincewidthandheightare public fields. - Aplet123