change unwrap to expect where WSL sometimes aborts (#4375)

* change unwrap to expect where WSL sometimes aborts

* clippy
This commit is contained in:
Rob Walker 2019-05-21 21:34:51 -07:00 committed by GitHub
parent 604071c5d8
commit de6838da78
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 9 additions and 2 deletions

View File

@ -32,8 +32,15 @@ const PLATFORM_FILE_EXTENSION_NATIVE: &str = "so";
const PLATFORM_FILE_EXTENSION_NATIVE: &str = "dll";
fn create_path(name: &str) -> PathBuf {
let current_exe = env::current_exe().unwrap();
let current_exe_directory = PathBuf::from(current_exe.parent().unwrap());
let current_exe = env::current_exe()
.unwrap_or_else(|e| panic!("create_path(\"{}\"): current exe not found: {:?}", name, e));
let current_exe_directory = PathBuf::from(current_exe.parent().unwrap_or_else(|| {
panic!(
"create_path(\"{}\"): no parent directory of {:?}",
name, current_exe,
)
}));
let library_file_name = PathBuf::from(PLATFORM_FILE_PREFIX_NATIVE.to_string() + name)
.with_extension(PLATFORM_FILE_EXTENSION_NATIVE);