From b6648ca8920a9a8d1281ef185f99df7e6cfc441a Mon Sep 17 00:00:00 2001 From: Bas Zalmstra Date: Fri, 16 Aug 2024 17:14:03 +0200 Subject: [PATCH] refactor: remove derivative dependency --- Cargo.lock | 12 ------------ Cargo.toml | 1 - src/verbatim_url.rs | 18 ++++++++++++++---- 3 files changed, 14 insertions(+), 17 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index cdbcd91..4f9f4ec 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -80,17 +80,6 @@ version = "1.0.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "baf1de4339761588bc0619e3cbc0120ee582ebb74b53b4efbf79117bd2da40fd" -[[package]] -name = "derivative" -version = "2.2.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "fcc3dd5e9e9c0b295d6e1e4d811fb6f157d5ffd784b8d202fc62eac8035a770b" -dependencies = [ - "proc-macro2", - "quote", - "syn 1.0.109", -] - [[package]] name = "form_urlencoded" version = "1.2.1" @@ -206,7 +195,6 @@ dependencies = [ name = "pep508_rs" version = "0.6.1" dependencies = [ - "derivative", "indoc", "log", "once_cell", diff --git a/Cargo.toml b/Cargo.toml index 81eb4ae..781a275 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -14,7 +14,6 @@ name = "pep508_rs" crate-type = ["cdylib", "rlib"] [dependencies] -derivative = "2.2.0" once_cell = "1.19.0" pep440_rs = "0.6.5" pyo3 = { version = "0.22", optional = true, features = ["abi3", "extension-module"] } diff --git a/src/verbatim_url.rs b/src/verbatim_url.rs index 6692fa7..765b487 100644 --- a/src/verbatim_url.rs +++ b/src/verbatim_url.rs @@ -1,5 +1,6 @@ use std::borrow::Cow; use std::fmt::Debug; +use std::hash::Hash; use std::ops::Deref; use std::path::{Component, Path, PathBuf}; @@ -8,8 +9,7 @@ use regex::Regex; use url::Url; /// A wrapper around [`Url`] that preserves the original string. -#[derive(Debug, Clone, Eq, derivative::Derivative)] -#[derivative(PartialEq, Hash)] +#[derive(Debug, Clone, Eq)] #[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))] pub struct VerbatimUrl { /// The parsed URL. @@ -22,11 +22,21 @@ pub struct VerbatimUrl { )] url: Url, /// The URL as it was provided by the user. - #[derivative(PartialEq = "ignore")] - #[derivative(Hash = "ignore")] given: Option, } +impl Hash for VerbatimUrl { + fn hash(&self, state: &mut H) { + self.url.hash(state); + } +} + +impl PartialEq for VerbatimUrl { + fn eq(&self, other: &Self) -> bool { + self.url == other.url + } +} + impl VerbatimUrl { /// Parse a URL from a string, expanding any environment variables. pub fn parse(given: impl AsRef) -> Result {