mirror of
https://github.com/astral-sh/uv.git
synced 2025-08-04 10:58:28 +00:00
Backport changes from publish crates (#1739)
Backport of changes for the published new versions of pep440_rs and pep508_rs to make it easier to keep them in sync.
This commit is contained in:
parent
8480842d3e
commit
2928c6e574
16 changed files with 121 additions and 120 deletions
|
@ -1,3 +1,4 @@
|
|||
#[cfg(feature = "serde")]
|
||||
use serde::{Deserialize, Deserializer, Serialize};
|
||||
use std::fmt;
|
||||
use std::fmt::{Display, Formatter};
|
||||
|
@ -13,7 +14,8 @@ use crate::{validate_and_normalize_owned, validate_and_normalize_ref, InvalidNam
|
|||
/// See:
|
||||
/// - <https://peps.python.org/pep-0685/#specification/>
|
||||
/// - <https://packaging.python.org/en/latest/specifications/name-normalization/>
|
||||
#[derive(Debug, Clone, PartialEq, Eq, Hash, PartialOrd, Ord, Serialize)]
|
||||
#[cfg_attr(feature = "serde", derive(Serialize))]
|
||||
#[derive(Debug, Clone, PartialEq, Eq, Hash, PartialOrd, Ord)]
|
||||
pub struct ExtraName(String);
|
||||
|
||||
impl ExtraName {
|
||||
|
@ -31,6 +33,7 @@ impl FromStr for ExtraName {
|
|||
}
|
||||
}
|
||||
|
||||
#[cfg(feature = "serde")]
|
||||
impl<'de> Deserialize<'de> for ExtraName {
|
||||
fn deserialize<D>(deserializer: D) -> Result<Self, D::Error>
|
||||
where
|
||||
|
|
|
@ -90,6 +90,7 @@ fn is_normalized(name: impl AsRef<str>) -> Result<bool, InvalidNameError> {
|
|||
Ok(true)
|
||||
}
|
||||
|
||||
/// Invalid [`crate::PackageName`] or [`crate::ExtraName`].
|
||||
#[derive(Clone, Debug, Eq, PartialEq)]
|
||||
pub struct InvalidNameError(String);
|
||||
|
||||
|
|
|
@ -1,6 +1,7 @@
|
|||
use std::borrow::Cow;
|
||||
use std::str::FromStr;
|
||||
|
||||
#[cfg(feature = "serde")]
|
||||
use serde::{Deserialize, Deserializer, Serialize};
|
||||
|
||||
use crate::{validate_and_normalize_owned, validate_and_normalize_ref, InvalidNameError};
|
||||
|
@ -11,21 +12,14 @@ use crate::{validate_and_normalize_owned, validate_and_normalize_ref, InvalidNam
|
|||
/// down to a single `-`, e.g., `---`, `.`, and `__` all get converted to just `-`.
|
||||
///
|
||||
/// See: <https://packaging.python.org/en/latest/specifications/name-normalization/>
|
||||
#[derive(
|
||||
Debug,
|
||||
Clone,
|
||||
PartialEq,
|
||||
Eq,
|
||||
Hash,
|
||||
PartialOrd,
|
||||
Ord,
|
||||
Serialize,
|
||||
rkyv::Archive,
|
||||
rkyv::Deserialize,
|
||||
rkyv::Serialize,
|
||||
#[cfg_attr(feature = "serde", derive(Serialize))]
|
||||
#[cfg_attr(
|
||||
feature = "rkyv",
|
||||
derive(rkyv::Archive, rkyv::Deserialize, rkyv::Serialize),
|
||||
archive(check_bytes),
|
||||
archive_attr(derive(Debug))
|
||||
)]
|
||||
#[archive(check_bytes)]
|
||||
#[archive_attr(derive(Debug))]
|
||||
#[derive(Debug, Clone, PartialEq, Eq, Hash, PartialOrd, Ord)]
|
||||
pub struct PackageName(String);
|
||||
|
||||
impl PackageName {
|
||||
|
@ -75,6 +69,7 @@ impl FromStr for PackageName {
|
|||
}
|
||||
}
|
||||
|
||||
#[cfg(feature = "serde")]
|
||||
impl<'de> Deserialize<'de> for PackageName {
|
||||
fn deserialize<D>(deserializer: D) -> Result<Self, D::Error>
|
||||
where
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue