既然 into 已经确定会进入即将发布的 3.9.0,我在找自己的代码里哪些地方可以用上它。
我想问的是,会不会用得太多?
比如看看我写的这些扩展。
extension [Element](items: IterableOnce[Element])
...
如果把它放宽成下面这样,会有什么坏处吗?
extension [Element](items: into[IterableOnce[Element]])
...
?
只要有转换到 IterableOnce 的 given 转换,我的扩展本来就能用。用了 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?