Removed expect
This commit is contained in:
@@ -1,6 +1,14 @@
|
||||
use std::ffi::NulError;
|
||||
|
||||
#[derive(Debug)]
|
||||
pub enum Error {
|
||||
Io,
|
||||
Parameter(String),
|
||||
Unknown
|
||||
}
|
||||
|
||||
impl From<NulError> for Error {
|
||||
fn from(_err: NulError) -> Error {
|
||||
Error::Io
|
||||
}
|
||||
}
|
||||
|
||||
@@ -12,7 +12,7 @@ impl Model {
|
||||
}
|
||||
|
||||
pub fn load(path: &str) -> Result<Self, Error> {
|
||||
let cpath = CString::new(path).expect("CString::new failed");
|
||||
let cpath = CString::new(path)?;
|
||||
let model = unsafe { mf_load_model(cpath.as_ptr()) };
|
||||
if model.is_null() {
|
||||
return Err(Error::Io);
|
||||
@@ -25,7 +25,7 @@ impl Model {
|
||||
}
|
||||
|
||||
pub fn save(&self, path: &str) -> Result<(), Error> {
|
||||
let cpath = CString::new(path).expect("CString::new failed");
|
||||
let cpath = CString::new(path)?;
|
||||
let status = unsafe { mf_save_model(self.model, cpath.as_ptr()) };
|
||||
if status != 0 {
|
||||
return Err(Error::Io);
|
||||
|
||||
Reference in New Issue
Block a user