Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fail => panic #50

Merged
merged 1 commit into from Oct 30, 2014
Merged
Changes from all commits
Commits
File filter...
Filter file types
Jump to…
Jump to file
Failed to load files.

Always

Just for now

fail => panic

  • Loading branch information
György Andrasek
György Andrasek committed Oct 30, 2014
commit 07ea2485f7bd03ed290f2322a39b6c13e4b303f6
@@ -137,7 +137,7 @@ pub fn load_png_from_memory(image: &[u8]) -> Result<Image,String> {
(ffi::COLOR_TYPE_PALETTE, 8) => (RGBA8, 4),
(ffi::COLOR_TYPE_GRAY, 8) => (K8, 1),
(ffi::COLOR_TYPE_GA, 8) => (KA8, 2),
_ => fail!("color type not supported"),
_ => panic!("color type not supported"),
};

let mut image_data = Vec::from_elem((width * height * pixel_width) as uint, 0u8);
@@ -164,7 +164,7 @@ pub extern fn write_data(png_ptr: *mut ffi::png_struct, data: *mut u8, length: s
let writer: &mut &mut io::Writer = mem::transmute(io_ptr);
slice::raw::buf_as_slice(&*data, length as uint, |buf| {
match writer.write(buf) {
Err(e) => fail!("{}", e.desc),
Err(e) => panic!("{}", e.desc),
_ => {}
}
});
@@ -176,7 +176,7 @@ pub extern fn flush_data(png_ptr: *mut ffi::png_struct) {
let io_ptr = ffi::png_get_io_ptr(png_ptr);
let writer: &mut &mut io::Writer = mem::transmute(io_ptr);
match writer.flush() {
Err(e) => fail!("{}", e.desc),
Err(e) => panic!("{}", e.desc),
_ => {}
}
}
@@ -252,7 +252,7 @@ mod test {
let file = "test/servo-screenshot.png";
let mut reader = match File::open_mode(&Path::new(file), io::Open, io::Read) {
Ok(r) => r,
Err(e) => fail!(e.desc),
Err(e) => panic!(e.desc),
};

let mut buf = Vec::from_elem(1024, 0u8);
@@ -266,13 +266,13 @@ mod test {

fn load_rgba8(file: &'static str, w: u32, h: u32) {
match load_png(&Path::new(file)) {
Err(m) => fail!(m),
Err(m) => panic!(m),
Ok(image) => {
assert_eq!(image.width, w);
assert_eq!(image.height, h);
match image.pixels {
RGBA8(_) => {}
_ => fail!("Expected RGBA8")
_ => panic!("Expected RGBA8")
}
}
}
@@ -295,15 +295,15 @@ mod test {
fn bench_file_from_memory(file: &'static str, w: u32, h: u32, c: &'static str) {
let mut reader = match File::open_mode(&Path::new(file), io::Open, io::Read) {
Ok(r) => r,
Err(e) => fail!("could not open '{}': {}", file, e.desc)
Err(e) => panic!("could not open '{}': {}", file, e.desc)
};
let buf = match reader.read_to_end() {
Ok(b) => b,
Err(e) => fail!(e)
Err(e) => panic!(e)
};
let bs = bench::benchmark(|b| b.iter(|| {
match load_png_from_memory(buf.as_slice()) {
Err(m) => fail!(m),
Err(m) => panic!(m),
Ok(image) => {
let color_type = match image.pixels {
K8(_) => "K8",
ProTip! Use n and p to navigate between commits in a pull request.
You can’t perform that action at this time.