mirror of
https://github.com/rust-lang/rust-analyzer.git
synced 2025-09-27 20:42:04 +00:00
Happy path implemented
This commit is contained in:
parent
0de71f7bc9
commit
8aa740dab4
8 changed files with 38 additions and 26 deletions
|
@ -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,
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue