pub struct FileId(/* private fields */);
Expand description
Identifies a file in a project or package.
This type is globally interned and thus cheap to copy, compare, and hash.
Implementations§
source§impl FileId
impl FileId
sourcepub fn new(package: Option<PackageSpec>, path: VirtualPath) -> Self
pub fn new(package: Option<PackageSpec>, path: VirtualPath) -> Self
Create a new interned file specification.
The path must start with a /
or this function will panic.
Note that the path is normalized before interning.
sourcepub fn new_fake(path: VirtualPath) -> Self
pub fn new_fake(path: VirtualPath) -> 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.
sourcepub fn package(&self) -> Option<&'static PackageSpec>
pub fn package(&self) -> Option<&'static PackageSpec>
The package the file resides in, if any.
sourcepub fn vpath(&self) -> &'static VirtualPath
pub fn vpath(&self) -> &'static VirtualPath
The absolute and normalized path to the file within the project or package.
sourcepub fn with_extension(&self, extension: &str) -> Self
pub fn with_extension(&self, extension: &str) -> Self
The same file location, but with a different extension.
Trait Implementations§
source§impl Ord for FileId
impl Ord for FileId
source§impl PartialOrd for FileId
impl PartialOrd for FileId
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 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§unsafe fn clone_to_uninit(&self, dst: *mut T)
unsafe fn clone_to_uninit(&self, dst: *mut T)
clone_to_uninit
)source§impl<Q, K> Comparable<K> for Q
impl<Q, K> Comparable<K> for Q
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