Closed nui closed 1 year ago
Why is it desired to re-export the module?
Why is it desired to re-export the module?
I actually don't need re-exporting.
Let say if this module is under crate::serde
I couldn't use it from crate::app::handler
because this module is private inside crate::serde
module by current generated output.
Is this an intended usage of this macro? If so, please add some note on macro documentation.
If you want to be able to use it anywhere in the crate, it needs to be at the root level of the crate. That's the same as any other module, and is trivially done with the existing macro.
That would pollute root level of crate.
Anyway I found a workaround.
const DATE_TIME_FORMAT: &[FormatItem<'_>] = time::macros::format_description!(
"hour=[hour], minute=[minute]"
);
// Makes a module `mod my_format { ... }`.
serde::format_description!(my_format_impl, OffsetDateTime, DATE_TIME_FORMAT);
// A hack module to exports method generated by above macro
pub mod my_format {
pub use super::my_format_impl::{deserialize, serialize};
}
Thanks for making this macro, it is pretty useful.
I will keep this issue as is, but feel free to close it.
time::serde::format_description
always generate module without visibility modifier. Would it be possible to add support for this functionality? I see no reason why it have to be private module only.I want to declare module in private module and publicly re export it but Rust doesn't allow re-exporting private items.
related link: https://docs.rs/time/latest/time/serde/macro.format_description.html