From 896d9f21c278e4a2aba416048f2c3ed9334bc395 Mon Sep 17 00:00:00 2001 From: Simon Walker Date: Fri, 23 Dec 2022 18:11:41 +0000 Subject: [PATCH] update example to not use stderr --- fitsio/examples/reading_from_memory.rs | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/fitsio/examples/reading_from_memory.rs b/fitsio/examples/reading_from_memory.rs index 930dfa0f..ab7d6a43 100644 --- a/fitsio/examples/reading_from_memory.rs +++ b/fitsio/examples/reading_from_memory.rs @@ -2,6 +2,8 @@ // can use `Fitsfile::from_raw` to load a `FitsFile` from a file that was opened via // `fits_open_memfile` in `cfitsio`. +#[cfg(all(target_pointer_width = "64", target_os = "linux"))] +use fitsio::errors::check_status; #[cfg(all(target_pointer_width = "64", target_os = "linux"))] use fitsio::{sys, FileOpenMode, FitsFile}; #[cfg(all(target_pointer_width = "64", target_os = "linux"))] @@ -10,6 +12,7 @@ use std::io::Read; #[cfg(all(target_pointer_width = "64", target_os = "linux"))] fn main() { // read the bytes into memory and return a pointer and length to the file + let (bytes, mut ptr_size) = { let filename = "./testdata/full_example.fits"; let mut f = std::fs::File::open(filename).unwrap(); @@ -39,10 +42,7 @@ fn main() { ); } - if status != 0 { - unsafe { sys::ffrprt(sys::stderr, status) }; - panic!("bad status"); - } + check_status(status).unwrap(); let mut f = unsafe { FitsFile::from_raw(fptr, FileOpenMode::READONLY) }.unwrap(); f.pretty_print().expect("pretty printing fits file");