XAMPPRocky / fluent-templates

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

0.8 breaking changes are a little bit obscure #43

Closed debug-richard closed 1 year ago

debug-richard commented 1 year ago

I am using fluent-templates in several projects with 400+ keys overall and tried to upgrade to 0.8.0. The issues are related to the #32 changes which add a Result return to all lookup functions.

I think that there should definitely be a function to query the existence of a key, but the change works against the practical usage. Or in other words, I have not needed such a return value once. This is also easily explained, why do I need a default handler for a fallback handler? I don't want to hardcode an additional default value for every case.

So I wrote a wrapper that works but I realized that it doesn't work for the tera/rocket handler because the static_loader can't be referenced easily. After two hours I gave up because I didn't want to write complicated code that does something that already worked perfectly.

With the new behavior the application panices every time a key can't be found. This is great if you write a new template and use placeholders.

I would like to change this again but the question is should the old behavior be restored and the result functions added under a new name or vice versa?

XAMPPRocky commented 1 year ago

Thank you for your issue! I would lean towards adding a try_ prefix to the new fn names, and have those return Results.