XAMPPRocky / fluent-templates

Easily add Fluent to your Rust project.
Apache License 2.0
136 stars 28 forks source link

Accept FnMut instead of fn pointer in ArcLoaderBuilder::customize #40

Closed xDarksome closed 1 year ago

xDarksome commented 1 year ago

Fn pointer isn't a great fit for public API as it doesn't allow capturing closures to coerce into it.

We have a use case in which we want to download remotely stored .ftl files and then inject them into ArcLoaderBuilder. To accomplish that a capturing closure is necessary.

This shouldn't be a breaking change, Box<dyn FnMut> won't allocate if a fn pointer is provided into ArcLoaderBuilder::customize, and the only downside here is dynamic dispatch.

XAMPPRocky commented 1 year ago

Thank you for your PR, and congrats on your first contribution! 🎉