Repository: astral-sh/uv
File: crates/uv-resolver/src/exclude_newer.rs (Rust)

Code before:
    PackageAdded(PackageName, PackageExcludeNewer),
    PackageRemoved(PackageName),
    PackageChanged(PackageName, Box<PackageExcludeNewerChange>),
}

impl ExcludeNewerPackageChange {
    pub fn is_relative_timestamp_change(&self) -> bool {
        match self {
            Self::PackageAdded(_, _) | Self::PackageRemoved(_) => false,
            Self::PackageChanged(_, change) => change.is_relative_timestamp_change(),
        }
    }
}

impl std::fmt::Display for ExcludeNewerPackageChange {
    fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
        match self {
            Self::PackageAdded(name, PackageExcludeNewer::Timestamp(value)) => {
                write!(
                    f,
                    "addition of exclude newer `{}` for package `{name}`",
                    value.as_ref()
                )
            }
            Self::PackageAdded(name, PackageExcludeNewer::Disabled) => {
                write!(f, "addition of exclude newer disable for package `{name}`")
            }
            Self::PackageRemoved(name) => {
                write!(f, "removal of exclude newer for package `{name}`")
            }
            Self::PackageChanged(name, change) => write!(f, "{change} for package `{name}`"),
        }
    }
}
/// A timestamp that excludes files newer than it.
#[derive(Debug, Clone, PartialEq, Eq)]
pub struct ExcludeNewerValue {
    /// The resolved timestamp.
    timestamp: Timestamp,
    /// The span used to derive the [`Timestamp`], if any.
    span: Option<ExcludeNewerSpan>,
}

impl ExcludeNewerValue {
    pub fn into_parts(self) -> (Timestamp, Option<ExcludeNewerSpan>) {
        (self.timestamp, self.span)
    }

    pub fn compare(&self, other: &Self) -> Option<ExcludeNewerValueChange> {
        match (&self.span, &other.span) {
            (None, Some(span)) => Some(ExcludeNewerValueChange::SpanAdded(*span)),

Review comment (suggestion):
Maybe?
```suggestion
                write!(f, "addition of exclude newer exception for package `{name}`")
```

Code after:
pub enum ExcludeNewerPackageChange {
    PackageAdded(PackageName, PackageExcludeNewer),
    PackageRemoved(PackageName),
    PackageChanged(PackageName, Box<PackageExcludeNewerChange>),
}

impl ExcludeNewerPackageChange {
    pub fn is_relative_timestamp_change(&self) -> bool {
        match self {
            Self::PackageAdded(_, _) | Self::PackageRemoved(_) => false,
            Self::PackageChanged(_, change) => change.is_relative_timestamp_change(),
        }
    }
}

impl std::fmt::Display for ExcludeNewerPackageChange {
    fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
        match self {
            Self::PackageAdded(name, PackageExcludeNewer::Enabled(value)) => {
                write!(
                    f,
                    "addition of exclude newer `{}` for package `{name}`",
                    value.as_ref()
                )
            }
            Self::PackageAdded(name, PackageExcludeNewer::Disabled) => {
                write!(
                    f,
                    "addition of exclude newer exclusion for package `{name}`"
                )
            }
            Self::PackageRemoved(name) => {
                write!(f, "removal of exclude newer for package `{name}`")
            }
            Self::PackageChanged(name, change) => write!(f, "{change} for package `{name}`"),
        }
    }
}
/// A timestamp that excludes files newer than it.
#[derive(Debug, Clone, PartialEq, Eq)]
pub struct ExcludeNewerValue {
    /// The resolved timestamp.
    timestamp: Timestamp,
    /// The span used to derive the [`Timestamp`], if any.
    span: Option<ExcludeNewerSpan>,
}

impl ExcludeNewerValue {
    pub fn into_parts(self) -> (Timestamp, Option<ExcludeNewerSpan>) {
        (self.timestamp, self.span)
    }