jmcnamara / rust_xlsxwriter

A Rust library for creating Excel XLSX files.
https://crates.io/crates/rust_xlsxwriter
Apache License 2.0
250 stars 23 forks source link

chores: remove unnecessary vec for custom_headers; generate absolute paths #70

Closed zjp-CN closed 6 months ago

zjp-CN commented 6 months ago

Related to https://github.com/jmcnamara/rust_xlsxwriter/issues/66

$ cargo expand -F serde --test integration serde14::create_new_xlsx_file_2

// for this
    #[derive(Serialize, ExcelSerialize)]
    #[serde(rename_all = "PascalCase")]
    struct MyStruct {
        field_1: u8,
        field_2: i8,
    }

// macro expansion
    #[doc(hidden)]
    const _: () = {
        impl ::rust_xlsxwriter::ExcelSerialize for MyStruct {
            fn to_serialize_field_options() -> ::rust_xlsxwriter::SerializeFieldOptions {
                let custom_headers = [
                    ::rust_xlsxwriter::CustomSerializeField::new("Field1"),
                    ::rust_xlsxwriter::CustomSerializeField::new("Field2"),
                ];
                ::rust_xlsxwriter::SerializeFieldOptions::new()
                    .set_struct_name("MyStruct")
                    .set_custom_headers(&custom_headers)
            }
        }
    };
jmcnamara commented 6 months ago

Thank you. Those are good changes.