Skip to content

Commit

Permalink
Small cleanup in path.rs
Browse files Browse the repository at this point in the history
  • Loading branch information
AlexWaygood committed Jul 5, 2024
1 parent 5f5ad70 commit 8a276b4
Showing 1 changed file with 9 additions and 15 deletions.
24 changes: 9 additions & 15 deletions crates/red_knot_module_resolver/src/path.rs
Original file line number Diff line number Diff line change
Expand Up @@ -123,8 +123,7 @@ impl ModuleResolutionPathBuf {
search_path: &Self,
typeshed_versions: &LazyTypeshedVersions,
) -> bool {
let as_ref = ModuleResolutionPathRef::from(self);
as_ref.is_directory(db, search_path, typeshed_versions)
ModuleResolutionPathRef::from(self).is_directory(db, search_path, typeshed_versions)
}

#[must_use]
Expand Down Expand Up @@ -300,17 +299,6 @@ impl<'a> ModuleResolutionPathRefInner<'a> {
}
}

#[must_use]
#[inline]
fn as_file_system_path(self) -> &'a FileSystemPath {
match self {
Self::Extra(path) => path,
Self::FirstParty(path) => path,
Self::StandardLibrary(path) => path,
Self::SitePackages(path) => path,
}
}

#[must_use]
fn with_pyi_extension(&self) -> ModuleResolutionPathBufInner {
match self {
Expand Down Expand Up @@ -487,13 +475,19 @@ impl<'a> From<&'a ModuleResolutionPathBuf> for ModuleResolutionPathRef<'a> {

impl PartialEq<FileSystemPath> for ModuleResolutionPathRef<'_> {
fn eq(&self, other: &FileSystemPath) -> bool {
self.0.as_file_system_path() == other
let fs_path = match self.0 {
ModuleResolutionPathRefInner::Extra(path) => path,
ModuleResolutionPathRefInner::FirstParty(path) => path,
ModuleResolutionPathRefInner::SitePackages(path) => path,
ModuleResolutionPathRefInner::StandardLibrary(path) => path,
};
fs_path == other
}
}

impl PartialEq<ModuleResolutionPathRef<'_>> for FileSystemPath {
fn eq(&self, other: &ModuleResolutionPathRef) -> bool {
self == other.0.as_file_system_path()
other == self
}
}

Expand Down

0 comments on commit 8a276b4

Please sign in to comment.