Use portable paths when serializing sources (#7504)

## Summary

Closes https://github.com/astral-sh/uv/issues/7493.
This commit is contained in:
Charlie Marsh 2024-09-18 14:51:14 -04:00 committed by GitHub
parent 1379b530f6
commit e36cc99b0d
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
8 changed files with 70 additions and 36 deletions

View file

@ -301,6 +301,17 @@ pub struct PortablePath<'a>(&'a Path);
#[derive(Debug, Clone, PartialEq, Eq)]
pub struct PortablePathBuf(PathBuf);
#[cfg(feature = "schemars")]
impl schemars::JsonSchema for PortablePathBuf {
fn schema_name() -> String {
PathBuf::schema_name()
}
fn json_schema(_gen: &mut schemars::gen::SchemaGenerator) -> schemars::schema::Schema {
PathBuf::json_schema(_gen)
}
}
impl AsRef<Path> for PortablePath<'_> {
fn as_ref(&self) -> &Path {
self.0