Simplify to_string_lossy()

Call .to_string_lossy() without trying .to_str() first.
This commit is contained in:
Alexander Krotov
2019-10-09 00:50:08 +03:00
committed by holger krekel
parent 102220834c
commit e4cca92910

View File

@@ -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 {