comparison rust/hg-core/src/utils.rs @ 46091:9eb07ab3f2d4

rhg: use persistent nodemap when available ? for node ID ? revision number lookups, instead on linear scan in a revlog. Differential Revision: https://phab.mercurial-scm.org/D9520
author Simon Sapin <simon-commits@exyr.org>
date Fri, 04 Dec 2020 17:27:10 +0100
parents 26114bd6ec60
children ca3f73cc3cf4
comparison
equal deleted inserted replaced
46090:8ff2d8359d0f 46091:9eb07ab3f2d4
165 impl<'a> Escaped for &'a HgPath { 165 impl<'a> Escaped for &'a HgPath {
166 fn escaped_bytes(&self) -> Vec<u8> { 166 fn escaped_bytes(&self) -> Vec<u8> {
167 self.as_bytes().escaped_bytes() 167 self.as_bytes().escaped_bytes()
168 } 168 }
169 } 169 }
170
171 // TODO: use the str method when we require Rust 1.45
172 pub(crate) fn strip_suffix<'a>(s: &'a str, suffix: &str) -> Option<&'a str> {
173 if s.ends_with(suffix) {
174 Some(&s[..s.len() - suffix.len()])
175 } else {
176 None
177 }
178 }