From e4cca92910a4a58aa04f58ac7039350d91237b86 Mon Sep 17 00:00:00 2001 From: Alexander Krotov Date: Wed, 9 Oct 2019 00:50:08 +0300 Subject: [PATCH] Simplify to_string_lossy() Call .to_string_lossy() without trying .to_str() first. --- src/dc_tools.rs | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/src/dc_tools.rs b/src/dc_tools.rs index 6a0362c95..4e8e6fb91 100644 --- a/src/dc_tools.rs +++ b/src/dc_tools.rs @@ -800,9 +800,7 @@ pub fn to_string_lossy(s: *const libc::c_char) -> String { let cstr = unsafe { CStr::from_ptr(s) }; - cstr.to_str() - .map(|s| s.to_string()) - .unwrap_or_else(|_| cstr.to_string_lossy().to_string()) + cstr.to_string_lossy().to_string() } pub fn as_str<'a>(s: *const libc::c_char) -> &'a str {