--- a/rust/hg-core/src/utils.rs Mon Sep 13 13:45:10 2021 +0200
+++ b/rust/hg-core/src/utils.rs Mon Sep 13 15:42:39 2021 +0200
@@ -74,6 +74,7 @@
fn trim(&self) -> &Self;
fn drop_prefix(&self, needle: &Self) -> Option<&Self>;
fn split_2(&self, separator: u8) -> Option<(&[u8], &[u8])>;
+ fn split_2_by_slice(&self, separator: &[u8]) -> Option<(&[u8], &[u8])>;
}
impl SliceExt for [u8] {
@@ -134,6 +135,14 @@
let b = iter.next()?;
Some((a, b))
}
+
+ fn split_2_by_slice(&self, separator: &[u8]) -> Option<(&[u8], &[u8])> {
+ if let Some(pos) = find_slice_in_slice(self, separator) {
+ Some((&self[..pos], &self[pos + separator.len()..]))
+ } else {
+ None
+ }
+ }
}
pub trait Escaped {