Mercurial > public > mercurial-scm > hg-stable
diff 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 |
line wrap: on
line diff
--- a/rust/hg-core/src/utils.rs Mon Dec 07 18:06:53 2020 +0100 +++ b/rust/hg-core/src/utils.rs Fri Dec 04 17:27:10 2020 +0100 @@ -167,3 +167,12 @@ self.as_bytes().escaped_bytes() } } + +// TODO: use the str method when we require Rust 1.45 +pub(crate) fn strip_suffix<'a>(s: &'a str, suffix: &str) -> Option<&'a str> { + if s.ends_with(suffix) { + Some(&s[..s.len() - suffix.len()]) + } else { + None + } +}