News for hackers. Stuff that matters.
Re:Why Discord is switching from Go to Rust by millstone on Tuesday February 04, 2020 @08:45PM (#22243243)
Rust has its share of random-feeling nonsense, like requiring PhantomData to "work around" unused type params, or that you can't compare arrays longer than 32 elements.
Re:Why Discord is switching from Go to Rust by gridspy on Tuesday February 04, 2020 @09:07PM (#22243348)
1. I've never had to use PhantomData since I started coding in rust pretty much fulltime 2 years ago. 2. You can compare arrays longer than 32, but the compiler will no longer create an automatic comparison for you. So it's not that you "can't" do it. -- That said, using == to compare >32 elements sounds inefficient, perhaps check your use-case?
Re:Why Discord is switching from Go to Rust by Jweb_Guru on Wednesday February 05, 2020 @02:57AM (#22244841)
It's not really a workaround (it didn't used to be required), it asks for PhantomData so it can figure out variance and infer auto traits.
Re:Why Discord is switching from Go to Rust by xmprt on Tuesday February 04, 2020 @09:39PM (#22243511)
Not comparing arrays longer than 32 elements by == sounds like a feature to me.
Re:Why Discord is switching from Go to Rust by millstone on Tuesday February 04, 2020 @10:02PM (#22243631)
The 32-count cliff is not just for Eq - it also defeats niceties like Debug, Hash, Default. This isn't a deliberate design decision, it's due to a (current) limitation of Rust's value-type generics.

The point is to illustrate that when you WTF using Rust, sometimes it's not you, it really is Rust.

Re:Why Discord is switching from Go to Rust by ElderKorihor on Tuesday February 04, 2020 @11:33PM (#22244055)
I think there are a few places were Rust didn't get it quite right, but this seems like a weird example. The 32 length limit is a temporary limitation, not a corner that Rust is painted into. Indeed, my understanding is that the limitation at this point is being maintained artificially due to an overabundance of caution (via https://doc.rust-lang.org/std/array/trait.LengthAtMost32.htm... ). That's not WTF, that's just TODO.
Re:Why Discord is switching from Go to Rust by lumost on Tuesday February 04, 2020 @10:46PM (#22243830)
A great example of this can be seen writing any recursive data-structure such as a doubly linked list.
Re:Why Discord is switching from Go to Rust by adamnemecek on Wednesday February 05, 2020 @10:42AM (#22247706)
Which language doesn't.