Mercurial > public > mercurial-scm > hg-stable
diff rust/hg-core/src/utils/hg_path.rs @ 47113:3da19db33cbc
dirstate-tree: Add map `get` and `contains_key` methods
Differential Revision: https://phab.mercurial-scm.org/D10369
author | Simon Sapin <simon.sapin@octobus.net> |
---|---|
date | Tue, 06 Apr 2021 14:35:39 +0200 |
parents | 6c778d20c8c2 |
children | be579775c2d9 |
line wrap: on
line diff
--- a/rust/hg-core/src/utils/hg_path.rs Tue Apr 06 14:29:05 2021 +0200 +++ b/rust/hg-core/src/utils/hg_path.rs Tue Apr 06 14:35:39 2021 +0200 @@ -226,6 +226,11 @@ inner.extend(other.as_ref().bytes()); HgPathBuf::from_bytes(&inner) } + + pub fn components(&self) -> impl Iterator<Item = &HgPath> { + self.inner.split(|&byte| byte == b'/').map(HgPath::new) + } + pub fn parent(&self) -> &Self { let inner = self.as_bytes(); HgPath::new(match inner.iter().rposition(|b| *b == b'/') {