1
2
3
4
5
6
7
8
9
use Customize;
use code_writer::CodeWriter;

/// Write serde attr according to specified codegen option.
pub fn write_serde_attr(w: &mut CodeWriter, customize: &Customize, attr: &str) {
    if customize.serde_derive.unwrap_or(false) {
        w.write_line(&format!("#[cfg_attr(feature = \"with-serde\", {})]", attr));
    }
}