« first day (1089 days earlier)      last day (2402 days later) » 

1:17 PM
Being POD isn't enough and we know it. :/ This is a tough one.
I fear we'll have to handpick known-to-be-safe cases.
 
@E_net4 FWIW, for a fixed hashmap of 12 values, I'd have just used an array of tuples
 
...
You probably meant to poke @набиячлэвэли?
 
What's the difference
but yes
 
@E_net4 Well, why not?
 
"because they're constant, which means their construction can never fail" — I'd argue with the logic of that
 
1:28 PM
@Shepmaster Me, too, but it's still kinda correct
@Shepmaster if it works once, it will always work
 
@набиячлэвэли POD types don't guarantee safe transmutation.
 
and it will always work once because it's hardcoded
@E_net4 Case?
 
Isn't .filter(Option::is_some).map(Option::unwrap) --> .filter_map(|x| x)?
 
@Shepmaster It... is. But I forgot about filter_map()
 
@набиячлэвэли u8 to bool is UB unless the value is either 0 or 1.
 
1:32 PM
@E_net4 Is it? Interesting.
 
@набиячлэвэли Yep. Any other value is an invalid state for bool. :/
 
@E_net4 That's kinda silly tbh
 
We could runtime check this, but it's an edge case. We'd better keep it as separate functions.
 
@набиячлэвэли I bet your changes to accept a String felt good
Although I'd suggest Into<String> (play.rust-lang.org/…)
 
Yep, Into<String> eez gud
@набиячлэвэли it's fine. Then the compiler can make equality checks trivial.
 
1:38 PM
@Shepmaster Dude, that's about 40x speedup in one bench and like ~160x in the other
@Shepmaster Damn, haven't thought of that
@E_net4 b == 1 rather than b != 0?
 
@набиячлэвэли b1 == b2 rather than !b1 == !b2.
 
@Shepmaster :thinking: if I took S: Into<String> && AsRef<str> that would be 100% ideal
 
1:54 PM
@набиячлэвэли Why do you say "and" in this case?
it has to implement both of those traits?
Almost sounds like you want Into<Cow<str>>
 
@Shepmaster Well sanitize_rfc822_like_date(), just Into<String>, yes. But parse_from_rfc2822_with_fallback() has a case where it does move out and a case where it doesn't.
@Shepmaster yeaaaaaaaaaaaaah, that's the one
 
2:06 PM
Hiiii @LukasKalbertodt
 
Hiiii @Shepmaster :3
Always confused why some people ask such low quality questions...
 
@LukasKalbertodt I'm always surprised at the problems that are caused by copy pasting, and the ones that could have been solved by copy-pasting
 
true :D
So many people also don't read error messages. I wonder if there is a terminal which directly posts to SO when a command returns with a non 0 return value...
 
ugggggggh, now it exists, because you said it
 
Who upvoted that question? 0__o
@набиячлэвэли @E_net4 I'd think the "bool can only be 0 or 1" is mostly to make memory layout optimizations possible...
 
2:19 PM
@LukasKalbertodt can you make an example of that?
 
@E_net4 A struct with 8 bool fields? :P feels like a lazy example, but I once used something similar in real code and I needed to hand optimize to save memory.
 
2:34 PM
I got a bug report to a library of mine and an indication that the reporter would help fix it.
That gives me the warm fuzzies
 
 
4 hours later…
7:02 PM
@LukasKalbertodt So like a bitset?
I doubt that optimisation'd be legal
 

« first day (1089 days earlier)      last day (2402 days later) »