-
-
Notifications
You must be signed in to change notification settings - Fork 1.6k
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
Allow non-type converter instances in ArrayConverter
and HashValueConverter
#10638
Allow non-type converter instances in ArrayConverter
and HashValueConverter
#10638
Conversation
ArrayConverter
and HashValueConverter
ArrayConverter
and HashValueConverter
Couldn't we just keep the class methods as is? |
Aren't they the same? 🤔 Though technically this is a breaking change because of going from |
There is at least one piece of code on GitHub that repeats the standard library's Would absolutely no breaking changes like this PR and the |
I think so
Introduce another type that provides the new features. I personally don't like it, but I think that's the way forward if we want to avoid breaking changes. |
Any suggestions for the new type's name? |
|
I would see a possibility to merge such a change. If it changes someones code, that's because they're using the API not in the way it is intended. We probably won't be able to stay 100% clear of breaking changes anyways, because fixing bugs can always mean breaking things. |
I think in this case it's probably fine to break things. I don't think these types are used a lot, as shown by that GitHub search. And we can always provide an upgrade path if needed, or actually help those shards in need. I have no idea why another shard would define those same types, maybe that's where the idea came from, or they couldn't wait for a release to have those types. |
What do you think about having a new class method
This is what I fear about; any bug fix can be considered a breaking change if any old code relies on the buggy behaviour prior to the fix. |
But, I'd prefer merging the module to struct conversion. |
Oh, adding We could change it to a |
Resolves part of #10637. Also adds specs for these converters since for some reason there weren't any.
The old class methods simply delegate to a new converter instance (e.g.
ArrayConverter(T).from_json
->ArrayConverter::WithInstance(T.class).new(T).from_json
); this has negligible impact on execution time, and LLVM can probably optimize out the temporary struct. We could deprecate the class methods later if that makes the interface cleaner.