New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Consider passing DataRequest, and other arguments, by value #1077
Comments
Do you agree with changing the DataProvider trait to take DataRequest by value? |
Seems fine, the request should 99% of the time be cheap to clone anyway |
I'm scope-creeping this issue to include options bags and other arguments. I think we haven't had a deep discussion about when to pass by reference and when to pass by value. Need updated input from: |
Options bags given at Formatter construction time, right? I think those should be by value, but if we ever pass additional options during formatting that should ideally be by reference. In particular: constructing a formatter is a "one time" operation, it should be fine to take ownership, and it makes sense for the formatter to need ownership of these things. It's a long lived object. However when a formatter is formatting something all of the parameters should be by-borrow or by-copy since that's a much more ephemeral operation. I feel like this matches the needs of Formatter objects anyway: options bags at creation would need to be owned, but additional options at format-time can just be read. (I don't think we really have "additional options at format time" anyway, though one could call the precision bits of FixedDecimal to be "additional options") |
I want to use this issue for DataRequest, and spawn a new issue for the options bags and other arguments that we should evaluate in Q1. |
I agree with Manish. |
Manish's options bag analysis seems reasonable to me. |
Original issue: There are several places where it would be useful for a DataProvider impl to have an owned DataRequest. It isn't clear why we're passing it by shared reference.
Scope increase: In general, what should be our style for when to take things by value versus by reference? DataRequest is an example of something we may as well take by value, but it's not the only one: options bags are borderline, as are locales, etc.
The text was updated successfully, but these errors were encountered: