diff --git a/rust/hg-core/src/lock.rs b/rust/hg-core/src/lock.rs --- a/rust/hg-core/src/lock.rs +++ b/rust/hg-core/src/lock.rs @@ -2,7 +2,6 @@ use crate::errors::HgError; use crate::errors::HgResultExt; -use crate::utils::StrExt; use crate::vfs::Vfs; use std::io; use std::io::ErrorKind; @@ -107,7 +106,7 @@ fn unlock(hg_vfs: Vfs, lock_filename: &s /// running anymore. fn lock_should_be_broken(data: &Option) -> bool { (|| -> Option { - let (prefix, pid) = data.as_ref()?.split_2(':')?; + let (prefix, pid) = data.as_ref()?.split_once(':')?; if prefix != &*LOCK_PREFIX { return Some(false); } diff --git a/rust/hg-core/src/utils.rs b/rust/hg-core/src/utils.rs --- a/rust/hg-core/src/utils.rs +++ b/rust/hg-core/src/utils.rs @@ -145,21 +145,6 @@ impl SliceExt for [u8] { } } -pub trait StrExt { - // TODO: Use https://doc.rust-lang.org/nightly/std/primitive.str.html#method.split_once - // once we require Rust 1.52+ - fn split_2(&self, separator: char) -> Option<(&str, &str)>; -} - -impl StrExt for str { - fn split_2(&self, separator: char) -> Option<(&str, &str)> { - let mut iter = self.splitn(2, separator); - let a = iter.next()?; - let b = iter.next()?; - Some((a, b)) - } -} - pub trait Escaped { /// Return bytes escaped for display to the user fn escaped_bytes(&self) -> Vec;