Use the canonical ImplementationName -> &str implementation (#14337)

Motivated by some code duplication highlighted in
https://github.com/astral-sh/uv/pull/14201, I noticed we weren't taking
advantage of the existing implementation for casting to a str here.
Unfortunately, we do need a special case for CPython still.
This commit is contained in:
Zanie Blue
2025-06-28 09:42:18 -05:00
committed by GitHub
parent db14cc3005
commit 692667cbb0
2 changed files with 15 additions and 5 deletions
+14
View File
@@ -44,6 +44,13 @@ impl ImplementationName {
Self::GraalPy => "GraalPy",
}
}
pub fn executable_name(self) -> &'static str {
match self {
Self::CPython => "python",
Self::PyPy | Self::GraalPy => self.into(),
}
}
}
impl LenientImplementationName {
@@ -53,6 +60,13 @@ impl LenientImplementationName {
Self::Unknown(name) => name,
}
}
pub fn executable_name(&self) -> &str {
match self {
Self::Known(implementation) => implementation.executable_name(),
Self::Unknown(name) => name,
}
}
}
impl From<&ImplementationName> for &'static str {