Теперь, когда into окончательно включили в предстоящий релиз 3.9.0, я ищу места в своём коде, где это могло бы пригодиться.
Меня интересует вот что: можно ли использовать это слишком часто?
Например, вот такие мои расширения:
extension [Element](items: IterableOnce[Element])
...
Есть ли минусы у более широкого варианта:
extension [Element](items: into[IterableOnce[Element]])
...
?
Мои расширения и так будут работать при наличии преобразований given в IterableOnce. С into разница лишь в отсутствии предупреждения. Это нежелательно? Короче, почему бы не расставить into по всему коду ради большей гибкости?
Переведено с английского·Показать оригиналWith into now settled for the forthcoming 3.9.0 release, I'm trying to identify parts of my code that could take advantage of it.
What I'm wondering is: Can it be used too much?
As an example, consider these extensions of mine:
extension [Element](items: IterableOnce[Element])
...
Would there be a downside to broadening that to:
extension [Element](items: into[IterableOnce[Element]])
...
?
My extensions would work regardless with given conversions into IterableOnce. With into, the difference is simply that no warning appears. Is that undesirable? In short, why shouldn't I scatter into throughout my code to gain more flexibilty?