Show More
@@ -2,7 +2,6 b'' | |||||
2 |
|
2 | |||
3 | use crate::errors::HgError; |
|
3 | use crate::errors::HgError; | |
4 | use crate::errors::HgResultExt; |
|
4 | use crate::errors::HgResultExt; | |
5 | use crate::utils::StrExt; |
|
|||
6 | use crate::vfs::Vfs; |
|
5 | use crate::vfs::Vfs; | |
7 | use std::io; |
|
6 | use std::io; | |
8 | use std::io::ErrorKind; |
|
7 | use std::io::ErrorKind; | |
@@ -107,7 +106,7 b' fn unlock(hg_vfs: Vfs, lock_filename: &s' | |||||
107 | /// running anymore. |
|
106 | /// running anymore. | |
108 | fn lock_should_be_broken(data: &Option<String>) -> bool { |
|
107 | fn lock_should_be_broken(data: &Option<String>) -> bool { | |
109 | (|| -> Option<bool> { |
|
108 | (|| -> Option<bool> { | |
110 |
let (prefix, pid) = data.as_ref()?.split_ |
|
109 | let (prefix, pid) = data.as_ref()?.split_once(':')?; | |
111 | if prefix != &*LOCK_PREFIX { |
|
110 | if prefix != &*LOCK_PREFIX { | |
112 | return Some(false); |
|
111 | return Some(false); | |
113 | } |
|
112 | } |
@@ -145,21 +145,6 b' impl SliceExt for [u8] {' | |||||
145 | } |
|
145 | } | |
146 | } |
|
146 | } | |
147 |
|
147 | |||
148 | pub trait StrExt { |
|
|||
149 | // TODO: Use https://doc.rust-lang.org/nightly/std/primitive.str.html#method.split_once |
|
|||
150 | // once we require Rust 1.52+ |
|
|||
151 | fn split_2(&self, separator: char) -> Option<(&str, &str)>; |
|
|||
152 | } |
|
|||
153 |
|
||||
154 | impl StrExt for str { |
|
|||
155 | fn split_2(&self, separator: char) -> Option<(&str, &str)> { |
|
|||
156 | let mut iter = self.splitn(2, separator); |
|
|||
157 | let a = iter.next()?; |
|
|||
158 | let b = iter.next()?; |
|
|||
159 | Some((a, b)) |
|
|||
160 | } |
|
|||
161 | } |
|
|||
162 |
|
||||
163 | pub trait Escaped { |
|
148 | pub trait Escaped { | |
164 | /// Return bytes escaped for display to the user |
|
149 | /// Return bytes escaped for display to the user | |
165 | fn escaped_bytes(&self) -> Vec<u8>; |
|
150 | fn escaped_bytes(&self) -> Vec<u8>; |
General Comments 0
You need to be logged in to leave comments.
Login now