mirror of
https://github.com/chatmail/core.git
synced 2026-05-08 09:26:29 +03:00
Simplify to_string_lossy()
Call .to_string_lossy() without trying .to_str() first.
This commit is contained in:
committed by
holger krekel
parent
102220834c
commit
e4cca92910
@@ -800,9 +800,7 @@ pub fn to_string_lossy(s: *const libc::c_char) -> String {
|
|||||||
|
|
||||||
let cstr = unsafe { CStr::from_ptr(s) };
|
let cstr = unsafe { CStr::from_ptr(s) };
|
||||||
|
|
||||||
cstr.to_str()
|
cstr.to_string_lossy().to_string()
|
||||||
.map(|s| s.to_string())
|
|
||||||
.unwrap_or_else(|_| cstr.to_string_lossy().to_string())
|
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn as_str<'a>(s: *const libc::c_char) -> &'a str {
|
pub fn as_str<'a>(s: *const libc::c_char) -> &'a str {
|
||||||
|
|||||||
Reference in New Issue
Block a user