2024-07-03 00:47:58 +00:00
|
|
|
use crate::Result;
|
|
|
|
|
|
2024-07-03 23:12:43 +00:00
|
|
|
pub const EMPTY: &str = "";
|
|
|
|
|
|
|
|
|
|
#[inline]
|
|
|
|
|
#[must_use]
|
|
|
|
|
pub fn split_once_infallible<'a>(input: &'a str, delim: &'_ str) -> (&'a str, &'a str) {
|
|
|
|
|
input.split_once(delim).unwrap_or((input, EMPTY))
|
|
|
|
|
}
|
|
|
|
|
|
2024-07-03 00:47:58 +00:00
|
|
|
/// Parses the bytes into a string.
|
|
|
|
|
pub fn string_from_bytes(bytes: &[u8]) -> Result<String> {
|
|
|
|
|
let str: &str = str_from_bytes(bytes)?;
|
|
|
|
|
Ok(str.to_owned())
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/// Parses the bytes into a string.
|
|
|
|
|
#[inline]
|
|
|
|
|
pub fn str_from_bytes(bytes: &[u8]) -> Result<&str> { Ok(std::str::from_utf8(bytes)?) }
|