Unnamed repository; edit this file 'description' to name the repository.
Diffstat (limited to 'crates/project-model/src/manifest_path.rs')
-rw-r--r--crates/project-model/src/manifest_path.rs16
1 files changed, 13 insertions, 3 deletions
diff --git a/crates/project-model/src/manifest_path.rs b/crates/project-model/src/manifest_path.rs
index d86e81e7e1..2331c0c36c 100644
--- a/crates/project-model/src/manifest_path.rs
+++ b/crates/project-model/src/manifest_path.rs
@@ -1,5 +1,5 @@
//! See [`ManifestPath`].
-use std::{fmt, ops, path::Path};
+use std::{borrow::Borrow, fmt, ops};
use paths::{AbsPath, AbsPathBuf};
@@ -38,6 +38,10 @@ impl ManifestPath {
pub fn canonicalize(&self) -> ! {
(**self).canonicalize()
}
+
+ pub fn is_rust_manifest(&self) -> bool {
+ self.file.extension().map_or(false, |ext| ext == "rs")
+ }
}
impl fmt::Display for ManifestPath {
@@ -54,8 +58,14 @@ impl ops::Deref for ManifestPath {
}
}
-impl AsRef<Path> for ManifestPath {
- fn as_ref(&self) -> &Path {
+impl AsRef<AbsPath> for ManifestPath {
+ fn as_ref(&self) -> &AbsPath {
self.file.as_ref()
}
}
+
+impl Borrow<AbsPath> for ManifestPath {
+ fn borrow(&self) -> &AbsPath {
+ self.file.borrow()
+ }
+}