From 3b5748277f3a29450efb750cf7098e6cc0f24306 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Stephan=20H=C3=BCgel?= Date: Mon, 16 Aug 2021 10:17:56 +0100 Subject: [PATCH] Remove null pointer check in favour of assert --- src/proj.rs | 6 +----- 1 file changed, 1 insertion(+), 5 deletions(-) diff --git a/src/proj.rs b/src/proj.rs index 5b38ed2c..4f110f13 100644 --- a/src/proj.rs +++ b/src/proj.rs @@ -94,8 +94,6 @@ pub enum ProjError { HeaderConversion(#[from] reqwest::header::ToStrError), #[error("A {0} error occurred for url {1} after {2} retries")] DownloadError(String, String, u8), - #[error("Got a null pointer while attempting to build an error String")] - NullPointer } /// The bounding box of an area of use @@ -127,15 +125,13 @@ impl Area { /// Easily get a String from the external library pub(crate) unsafe fn _string(raw_ptr: *const c_char) -> Result { - if raw_ptr.is_null() { - return Err(ProjError::NullPointer); - } let c_str = CStr::from_ptr(raw_ptr); Ok(str::from_utf8(c_str.to_bytes())?.to_string()) } /// Look up an error message using the error code fn error_message(code: c_int) -> Result { + assert_ne!(code, 0); unsafe { let rv = proj_errno_string(code); _string(rv)