fix rust fmt

This commit is contained in:
holger krekel
2019-07-20 15:14:11 +02:00
parent 496e980a17
commit 1ad45ed4d6

View File

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