639993edd7
Former-commit-id: b9f0ccaf1820da61f49ebeb2af5beff5cccd722f
21 lines
450 B
Rust
21 lines
450 B
Rust
use std::fs::File;
|
|
use std::io;
|
|
use std::io::prelude::*;
|
|
|
|
pub fn read_bin_file(filename: &str) -> io::Result<Vec<u8>> {
|
|
let mut buf = Vec::new();
|
|
let mut file = File::open(filename)?;
|
|
file.read_to_end(&mut buf)?;
|
|
Ok(buf)
|
|
}
|
|
|
|
#[macro_export]
|
|
macro_rules! index2d {
|
|
($x:expr, $y:expr, $w:expr) => {
|
|
$w * $y + $x
|
|
};
|
|
($t:ty, $x:expr, $y:expr, $w:expr) => {
|
|
(($w as $t) * ($y as $t) + ($x as $t)) as $t
|
|
};
|
|
}
|