Skip to content

refactor: unwrap to expect in error.rs #347

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

Merged
merged 1 commit into from
Oct 28, 2022
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 4 additions & 1 deletion src/error.rs
Original file line number Diff line number Diff line change
Expand Up @@ -91,7 +91,10 @@ pub fn panic_on_tskit_error(code: i32) {
/// if the system runs out of memory.
pub fn get_tskit_error_message(code: i32) -> String {
let c_str = unsafe { std::ffi::CStr::from_ptr(crate::bindings::tsk_strerror(code)) };
c_str.to_str().unwrap().to_owned()
c_str
.to_str()
.expect("failed to convert c_str to &str")
.to_owned()
}

/// Given an instance of [``TskReturnValue``](crate::TskReturnValue),
Expand Down