Unnamed repository; edit this file 'description' to name the repository.
Diffstat (limited to 'crates/vfs/src/lib.rs')
-rw-r--r--crates/vfs/src/lib.rs14
1 files changed, 12 insertions, 2 deletions
diff --git a/crates/vfs/src/lib.rs b/crates/vfs/src/lib.rs
index 7360f68c73..8ffda5d78d 100644
--- a/crates/vfs/src/lib.rs
+++ b/crates/vfs/src/lib.rs
@@ -60,11 +60,21 @@ pub use paths::{AbsPath, AbsPathBuf};
///
/// Most functions in rust-analyzer use this when they need to refer to a file.
#[derive(Copy, Clone, Debug, Ord, PartialOrd, Eq, PartialEq, Hash)]
-pub struct FileId(pub u32);
+pub struct FileId(u32);
impl FileId {
/// Think twice about using this outside of tests. If this ends up in a wrong place it will cause panics!
- pub const BOGUS: FileId = FileId(u32::MAX);
+ pub const BOGUS: FileId = FileId(0xe4e4e);
+
+ #[inline]
+ pub fn from_raw(raw: u32) -> FileId {
+ FileId(raw)
+ }
+
+ #[inline]
+ pub fn index(self) -> u32 {
+ self.0
+ }
}
/// safe because `FileId` is a newtype of `u32`