« first day (2005 days earlier)      last day (1477 days later) » 

1:10 PM
... i am confuse
 
@E_net4thecommentflagger I spend 30m trying to understand why it's doesn't work :p
 
 
2 hours later…
3:29 PM
How do we feel about the general idea of
#[repr(C)]
struct Header {
    id: u8,
    size: u64,
    more_stuff: u16,
}
And then reading in mem::size_of::<Header>() bytes and transmuting
 
@Shepmaster What about the alignment?
 
 
1 hour later…
4:39 PM
3
A: Transmuting u8 buffer to struct in Rust

ShepmasterIf you don't want to copy the data to the struct but instead leave it in place, you can use slice::align_to. This creates a &MyStruct instead: #[repr(C, packed)] #[derive(Debug, Copy, Clone)] struct MyStruct { foo: u16, bar: u8, } fn main() { let v = vec![1u8, 2, 3]; // I copie...

It's just annoying to write all the
write_field_1()
write_field_2()
write_field_3()
 
Should be fine then
 
but this way also involves unsafe
 

« first day (2005 days earlier)      last day (1477 days later) »