These are chat archives for rust-lang/rust

May 2017
Sherzod Mutalov
May 19 2017 01:37
Denis Bakunovitch
May 19 2017 02:36
Newbie question: is there a nice way to perform something like this: bytes[0...0x40].unpack('Z*@52L<3') (here it unpacks a slice of 64 bytes into a null-terminated string and three LE 32-bit numbers) without spaghetti of transmutes and/or byteorder::read_u32?
Here's what I'm currently doing (different structure from the example before, but you get the gist):
let raw_name = decrypted_toc_buffer.get(j..j+0x38).unwrap();
let mut raw_usizes = Cursor::new(decrypted_toc_buffer.get(j+0x38..j+0x40).unwrap());

let offset = raw_usizes.read_u32::<LittleEndian>();
let size = raw_usizes.read_u32::<LittleEndian>();
let name = String::from_utf8({
            let mut n = Vec::new();
I am kinda okay with the byteorder's read functions, but the way I am working with strings feels fundamentally wrong.
Joonas Koivunen
May 19 2017 07:09
@atzkey i'm not aware of any library providing the unpack alike functionality... in your code sample, what is the type of decrypted_toc_buffer?
@atzkey in general, null terminated strings are not used (neither str or String is null terminated)
Denis Bakunovitch
May 19 2017 10:17
@koivunej Null-terminated string were just an explanation of what unpack does in an example above. My buffers are mut [u8].
Joonas Koivunen
May 19 2017 10:20
@atzkey oki.. I did not know that slices have fn get(&self) as I usually use &decrypted_toc_buffer[j..j+0x38] but I would handle the String creation by str::from_utf8(raw_name).into_owned()
@atzkey other than that I do not know of any nicer ways of reading in structs. my reading code looks really similar, except that I use raw_usizes.read_u32::<LittleEndian>()?; (? operator)
Masaki Hara
May 19 2017 12:03
What is the relation between RFC 0192 (default bounds derived from the trait itself) and RFC 0599/1156 (default bounds derived from the enclosing type)? I looked into the compiler and it seems that the actual implementation is a mixture of 0192 and 0599/1156. However, RFC 0599 doesn't even mention about 0192.
Christopher Davenport
May 19 2017 12:26
Does anyone have a somewhat current example of a simple game like Snake, basically a minimal example of logic mixed with graphics.
Christopher Davenport
May 19 2017 12:36
Yup, except that it actually has to be able to compile. And preferably lets me understand the current piston-api in action as that is no longer consistent with the newer api.
Christopher Davenport
May 19 2017 12:41
I have had a lot of difficulty looking for newer minimal examples of using piston. I can make a square twirl but not sure how to get from there to a minimal working example.
Mick van Gelderen
May 19 2017 15:03
Hey guys, I want to debug my failing unit test but have no clue how to go about it. Has anyone tried something similar before?
May 19 2017 19:57
Hey guys, feel free to review my upcoming conference talk draft