Happy path implemented

This commit is contained in:
Kirill Bulatov 2020-09-04 02:25:00 +03:00
parent 0de71f7bc9
commit 8aa740dab4
8 changed files with 38 additions and 26 deletions

View file

@ -48,10 +48,12 @@ impl VfsPath {
(VfsPathRepr::VirtualPath(_), _) => false,
}
}
pub fn ends_with(&self, suffix: &str) -> bool {
match &self.0 {
VfsPathRepr::PathBuf(p) => p.ends_with(suffix),
VfsPathRepr::VirtualPath(p) => p.ends_with(suffix),
pub fn parent(&self) -> Option<VfsPath> {
let mut parent = self.clone();
if parent.pop() {
Some(parent)
} else {
None
}
}
@ -265,9 +267,6 @@ impl VirtualPath {
fn starts_with(&self, other: &VirtualPath) -> bool {
self.0.starts_with(&other.0)
}
fn ends_with(&self, suffix: &str) -> bool {
self.0.ends_with(suffix)
}
fn pop(&mut self) -> bool {
let pos = match self.0.rfind('/') {
Some(pos) => pos,