Closed zbraniecki closed 4 years ago
Related: we could also consider removing errors
from the signature of format_pattern
.
Related: we could also consider removing errors from the signature of format_pattern.
What do you mean by that?
Since errors would be returned from format_pattern
(wrapped in an Option
), I think there's little use left for the third argument to format_pattern
. We could thus change:
let value = bundle.format_pattern(&pattern, Some(&args), &mut errors);
to:
let (value, maybe_errors) = bundle.format_pattern(&pattern, Some(&args));
Ah yes, that was my thinking as well!
This gets moved to 0.8.
I actually went the other direction - I now accept a &Vec
of Errors that FluentBundle
populates. I think this is a better approach as it allows the user to decide how to handle errors (per format, or per list of formats) without any additional allocations.
I may also switch to allow not to pass the errors in which case errors won't be populated at all.
I'm going to close it. I believe that errors vec should not be allocated as part of the return value, and instead should be passed to the call in some higher level code that will handle the outcome of errors (fallbacks, reporting etc.).
Are you still planning to change the return value of
format_pattern
to(String, Option<Vec<Error>>)
?Originally posted by @stasm in https://github.com/projectfluent/fluent-rs/pull/120