comparison 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
comparison
equal deleted inserted replaced
47112:d7631d55da3e 47113:3da19db33cbc
224 inner.push(b'/'); 224 inner.push(b'/');
225 } 225 }
226 inner.extend(other.as_ref().bytes()); 226 inner.extend(other.as_ref().bytes());
227 HgPathBuf::from_bytes(&inner) 227 HgPathBuf::from_bytes(&inner)
228 } 228 }
229
230 pub fn components(&self) -> impl Iterator<Item = &HgPath> {
231 self.inner.split(|&byte| byte == b'/').map(HgPath::new)
232 }
233
229 pub fn parent(&self) -> &Self { 234 pub fn parent(&self) -> &Self {
230 let inner = self.as_bytes(); 235 let inner = self.as_bytes();
231 HgPath::new(match inner.iter().rposition(|b| *b == b'/') { 236 HgPath::new(match inner.iter().rposition(|b| *b == b'/') {
232 Some(pos) => &inner[..pos], 237 Some(pos) => &inner[..pos],
233 None => &[], 238 None => &[],