mirror of
https://github.com/chatmail/core.git
synced 2026-04-22 16:06:30 +03:00
prefer to_opt_string_lossy() over as_opt_str() as the latter pancis on non-wellformatted utf-8, delete as_opt_str()
This commit is contained in:
committed by
holger krekel
parent
e4b3e23769
commit
858baf0c2c
@@ -713,14 +713,6 @@ pub fn as_str<'a>(s: *const libc::c_char) -> &'a str {
|
||||
as_str_safe(s).unwrap_or_else(|err| panic!("{}", err))
|
||||
}
|
||||
|
||||
/// Converts a C string to either a Rust `&str` or `None` if it is a null pointer.
|
||||
pub fn as_opt_str<'a>(s: *const libc::c_char) -> Option<&'a str> {
|
||||
if s.is_null() {
|
||||
return None;
|
||||
}
|
||||
Some(as_str(s))
|
||||
}
|
||||
|
||||
fn as_str_safe<'a>(s: *const libc::c_char) -> Result<&'a str, Error> {
|
||||
assert!(!s.is_null(), "cannot be used on null pointers");
|
||||
|
||||
|
||||
Reference in New Issue
Block a user