mirror of
https://github.com/chatmail/core.git
synced 2026-05-08 17:36:29 +03:00
fix rust fmt
This commit is contained in:
@@ -1561,11 +1561,14 @@ pub fn to_string(s: *const libc::c_char) -> String {
|
|||||||
let cstr = unsafe { CStr::from_ptr(s) };
|
let cstr = unsafe { CStr::from_ptr(s) };
|
||||||
|
|
||||||
cstr.to_str().map(|s| s.to_string()).unwrap_or_else(|err| {
|
cstr.to_str().map(|s| s.to_string()).unwrap_or_else(|err| {
|
||||||
panic!("Non utf8 string: '{:?}' ({:?})", cstr.to_string_lossy(), err);
|
panic!(
|
||||||
|
"Non utf8 string: '{:?}' ({:?})",
|
||||||
|
cstr.to_string_lossy(),
|
||||||
|
err
|
||||||
|
);
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
pub fn to_string_lossy(s: *const libc::c_char) -> String {
|
pub fn to_string_lossy(s: *const libc::c_char) -> String {
|
||||||
if s.is_null() {
|
if s.is_null() {
|
||||||
return "".into();
|
return "".into();
|
||||||
@@ -1573,9 +1576,9 @@ 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().map(|s| s.to_string()).unwrap_or_else(|_| {
|
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