Skip to content

Commit

Permalink
Merge pull request #17 from baszalmstra/refactor/remove_derivative
Browse files Browse the repository at this point in the history
refactor: remove derivative dependency
  • Loading branch information
konstin authored Aug 19, 2024
2 parents 3cc8997 + b6648ca commit bd28f9b
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 17 deletions.
12 changes: 0 additions & 12 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 0 additions & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -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"] }
Expand Down
18 changes: 14 additions & 4 deletions src/verbatim_url.rs
Original file line number Diff line number Diff line change
@@ -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};

Expand All @@ -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.
Expand All @@ -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<String>,
}

impl Hash for VerbatimUrl {
fn hash<H: std::hash::Hasher>(&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<str>) -> Result<Self, VerbatimUrlError> {
Expand Down

0 comments on commit bd28f9b

Please sign in to comment.