add split_once_infallible string util
Signed-off-by: Jason Volk <jason@zemos.net>
This commit is contained in:
parent
4f5c6de853
commit
177c9e8bfa
1 changed files with 8 additions and 0 deletions
|
@ -1,5 +1,13 @@
|
|||
use crate::Result;
|
||||
|
||||
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))
|
||||
}
|
||||
|
||||
/// Parses the bytes into a string.
|
||||
#[inline]
|
||||
pub fn string_from_bytes(bytes: &[u8]) -> Result<String> {
|
||||
|
|
Loading…
Add table
Reference in a new issue