« first day (2293 days earlier)      last day (1194 days later) » 

12:14 AM
@EnnMichael there are plenty of ways of building or contributing to software that can help empower others.
 
 
3 hours later…
2:56 AM
Software is definitely not negative in value! I used to work using software that enabled construction workers to do their job, and writing tools for it. Without the software, buildings would take far longer to get built - there'd be a lot more manual error, too.
Now I work on software used for geological analysis, and it's important for understanding what's necessary to mitigate consequences from industry, or for help in remediation. And for planning for large-scale structures that need to consider geology, like highways and bridges
But setting that aside, entertainment is necessary! Humans aren't machines - I can't just work all the time, or all of when I'm not sleeping and eating. I need other things, and entertainment is one of them.
 
 
4 hours later…
6:49 AM
@PeterVaro most simple (and silly) names are already "reserved" in crates.io
I don't really like the name I've taken but suspecting I would be the only one to use it, I didn't too much time on the name
@Shepmaster You made me look. There's a tap crate which does exactly the same
(or more)
 
 
2 hours later…
8:59 AM
Morning!
 
9:22 AM
If I have four 32 bit values (u32) and I’d want to fit them into [u8; 16] would transmute be an option and/or what would the downsides be to using it?
The gist of the docs on transmute seems to be “Please don’t use this unless it’s absolutely necessary or you know exactly what you’re doing.” I can’t say I meet those two conditions, but I wondered.
I used copy_from_slice() at first, but I’m currently doing it by shifting and masking bits, which works.
 
9:42 AM
@Jason When you say "I have four 32 bits values" do you mean sequential (e.g. [u32; 4] or in a packed struct)?
 
9:56 AM
@PeterVaro sequential, i.e. [A, B, C, D] all u32, but I could move it into a struct.
 
It does not need to be moved. It just need to be laid out sequentially in the memory without padding bytes between them, which you can achieve in several ways, I mentioned two: a primitive, fixed-size array, and a packed struct.
Both can be safely transmuted to fixed size u8 array and could be read from it. The only thing you have to keep in mind (however it is very unlikely that you're dealing with such thing) and that is the endianness when interpret these values.
I believe the warning in the std documentation is more likely an attempt to scare you off: if you need conversion, use/implement the traits provided by std::convert. But low level type-casting, which is what you do here, is a perfect example where transmute actually makes perfect sense.
 
Ah, yes, I am messing around with the endianness. It’s related to the MD5 algorithm.
Just a minute, thanks for your explanation @PeterVaro I’m on mobile and the chat isn’t the easiest to use here!
 
@Jason It isn't the easiest to use on the desktop either :upside_down_smile:
 
11:03 AM
Thanks @PeterVaro, I think I should really give all of this a good read doc.rust-lang.org/nomicon/data.html
The introduction is quite funny :-)
 
 
4 hours later…
3:30 PM
(removed)
 
Had a brain fart
 
3:43 PM
@Jason Do that, as well as look at the reference, but most importantly, look at the Alternatives section at transmute's documentation. If you cannot find anything that satisfies your requirements, then go on and use transmute itself. I shalt not cast a stone at thee!
 
3:54 PM
@PeterVaro Haha, will do :p
 
Oooor maybe look for libraries that assist you in that.
 
I think I'll avoid the use of transmute for now in the final implementation, but it's fun to learn more about it. I only ended up using it at the very end of the hash computation, where the four u32 registers are added, which I suppose is the least computationally expensive part.
 
4:13 PM
I can't justify the use of `unsafe is what I tried to say. If I wanted it to be fast I suppose writing a GPU implementation would be a better way to go about it.
@E_net4thecurator Is there such a library for conversion or do you mean the hashing algorithm itself? I'd of course use a crate by people that know what they're doing for the latter.
 
@Jason Why not both? :)
For safer transmutations, I co-maintain safe-transmute, but many others are out there.
 
@E_net4thecurator Oh, that's cool! I'll have a look!
 
@E_net4thecurator Shameless plug
 
A Rust working group specifically working on extending Rust (core/std) with safer constructs.
@EnnMichael Heh, I did add a disclaimer.
It was that or do yet another lookup.
 
4:26 PM
@E_net4thecurator True that
 
@E_net4thecurator I didn't know about this, cool!
 
Yep, better alternatives may one day become available without any extra crates.
Which kind of makes sense here, considering that the compiler is expected to have extra power over the type system.
 

« first day (2293 days earlier)      last day (1194 days later) »