Skip to content

Instantly share code, notes, and snippets.

@Leonidas-from-XIV
Created April 14, 2014 09:47
Show Gist options
  • Select an option

  • Save Leonidas-from-XIV/10633161 to your computer and use it in GitHub Desktop.

Select an option

Save Leonidas-from-XIV/10633161 to your computer and use it in GitHub Desktop.
fn read_u64(mut from: File, n: uint) -> ~[u64] {
let mut buffer: Vec<u8> = Vec::with_capacity(n * 4);
let mut buf = buffer.as_mut_slice();
match from.read(buf) {
Ok(_) => (),
Err(e) => fail!("reading failed {}", e),
};
let v: ~[u64] = unsafe { std::cast::transmute(buf) };
v
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment