News for hackers. Stuff that matters.
Re:Three Minor Features in Go 1.18 by tialaramex on Wednesday December 22, 2021 @05:40PM (#29656421)
Yes, I use this much more often than the more powerful general split feature, it feels very "right-sized".

split_once() and similar split features in Rust are interesting because Rust doesn't have overloading, yet you can split on a string, or a character. This relies on a Trait, Pattern, that is Nightly, so you can't Implement it yourself in stable Rust today, but eventually this factors out the commonality which is cleverer than overloading (because it applies everywhere automatically)

Re:Three Minor Features in Go 1.18 by IshKebab on Thursday December 23, 2021 @06:13PM (#29667681)
You can implement it yourself. You just have to use your own trait.
Re:Three Minor Features in Go 1.18 by tialaramex on Sunday December 26, 2021 @07:19PM (#29697692)
I stared at this a few times and I don't get it.

The point is you can't implement Pattern, because it's a nightly feature. If you just make your own, that isn't Pattern and provides none of the benefits.

Yes, you can implement your own trait, and provide blanket implementations for it, but unlike Pattern yours is not part of the standard.

The nice thing about Pattern is that if Rust added say split_exactly_six_times() to the standard library that would take separator: Pattern too and so things which implement Pattern qualify, I can't see a way to get that benefit for my own traits.