pub struct FileId(/* private fields */);Expand description
An interned version of RootedPath.
This type is globally interned and thus cheap to copy, compare, and hash.
Implementations§
Source§impl FileId
impl FileId
Sourcepub fn new(path: RootedPath) -> Self
pub fn new(path: RootedPath) -> Self
Create a new interned file specification.
This is the same as RootedPath::intern.
Sourcepub fn unique(path: RootedPath) -> Self
pub fn unique(path: RootedPath) -> Self
Create a new unique (“fake”) file specification, which is not accessible by path.
Caution: the ID returned by this method is the only identifier of the file, constructing a file ID with a path will not reuse the ID even if the path is the same. This method should only be used for generating “virtual” file ids such as content read from stdin.
While the returned ID is not otherwise accessible, the provided root and path still matter as they define how paths within the identified file will resolve. For the example of content read from stdin, it will define how a relative path in the stdin content is resolved.
Sourcepub const fn from_raw(v: NonZeroU16) -> Self
pub const fn from_raw(v: NonZeroU16) -> Self
Construct from a raw number.
Should only be used with numbers retrieved via
into_raw. Misuse may results in panics, but no
unsafety.
Sourcepub const fn into_raw(self) -> NonZeroU16
pub const fn into_raw(self) -> NonZeroU16
Extract the raw underlying number.
Sourcepub fn get(&self) -> &'static RootedPath
pub fn get(&self) -> &'static RootedPath
Get the static, interned rooted path.
Methods from Deref<Target = RootedPath>§
Sourcepub fn root(&self) -> &VirtualRoot
pub fn root(&self) -> &VirtualRoot
The root this path resides in.
Sourcepub fn package(&self) -> Option<&PackageSpec>
👎Deprecated: use root instead
pub fn package(&self) -> Option<&PackageSpec>
use root instead
The package the path resides in, if any.
Sourcepub fn vpath(&self) -> &VirtualPath
pub fn vpath(&self) -> &VirtualPath
The absolute and normalized path to the file within the project or package.
Sourcepub fn map(&self, f: impl FnOnce(&VirtualPath) -> VirtualPath) -> Self
pub fn map(&self, f: impl FnOnce(&VirtualPath) -> VirtualPath) -> Self
Maps the virtual path while retaining the root.
Trait Implementations§
impl Copy for FileId
impl Eq for FileId
impl StructuralPartialEq for FileId
Auto Trait Implementations§
impl Freeze for FileId
impl RefUnwindSafe for FileId
impl Send for FileId
impl Sync for FileId
impl Unpin for FileId
impl UnsafeUnpin for FileId
impl UnwindSafe for FileId
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
Source§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
Source§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
Source§fn equivalent(&self, key: &K) -> bool
fn equivalent(&self, key: &K) -> bool
key and return true if they are equal.Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self>
fn into_either(self, into_left: bool) -> Either<Self, Self>
self into a Left variant of Either<Self, Self>
if into_left is true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
self into a Left variant of Either<Self, Self>
if into_left(&self) returns true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read more