tuwunel_core/utils/string/
split.rs1use super::EMPTY;
2
3type Pair<'a> = (&'a str, &'a str);
4
5pub trait SplitInfallible<'a> {
7 fn split_once_infallible(&self, delim: &str) -> Pair<'a>;
10
11 fn rsplit_once_infallible(&self, delim: &str) -> Pair<'a>;
14}
15
16impl<'a> SplitInfallible<'a> for &'a str {
17 #[inline]
18 fn rsplit_once_infallible(&self, delim: &str) -> Pair<'a> {
19 self.rsplit_once(delim).unwrap_or((self, EMPTY))
20 }
21
22 #[inline]
23 fn split_once_infallible(&self, delim: &str) -> Pair<'a> {
24 self.split_once(delim).unwrap_or((self, EMPTY))
25 }
26}