3 ms·
Gankra is the most entertaining Rust author (Rust programmer who writes about Rust). Easily.
by avgcorrection 4y ago
Gankra is the most entertaining Rust author (Rust programmer who writes about Rust). Easily.
- robby_w_g 4y agoThere's an unreasonably grumpy commenter below that disagrees, but I personally agree with you and found this to be a fun read. I was interested in the topic before reading, but it could have easily been a slog of technical minutia. I'm glad that wasn't the case! Edit: the comment I referenced was deleted in the time I took to post this. It's probably for the best
- tialaramex 4y agoMmm. I think @m_ou_se is probably the most entertaining at least if we consider that both Saturday Night Live and Nightmare On Elm Street is entertainment. For example, Rust deliberately doesn't have the tertiary operator, and random other types don't get silently coerced as booleans - so you can't write a = x ? 1 : -1; however you can write a = if x != 0 { 1 } else { -1 }; with the same effect. But Mara isn't satisfied with this verbose yet sensible answer, and proposes you could instead, for example: a = x.count_ones().count_ones().count_ones().count_ones() as i32 * 2 - 1; Hilarious? Or maybe terrifying? Entertaining certainly. https://twitter.com/m_ou_se/status/1404034056405368833?lang=en https://twitter.com/m_ou_se/status/1404034056405368833?lang=... Aria is more informative but I'm not going to end up choking and spilling my beverage all over the desk.
- GolDDranks 4y agoThat's a hilarious code crime! I checked it and it turns out that this works for 64-bit integers too. It's 2^128 - 1 that is the first number that requires five calls to count_ones to work!
- pbsd 4y agoYou could also do `1|!((x|-x)>>30)`