Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

refactor: remove derivative dependency #17

Merged
merged 1 commit into from
Aug 19, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
refactor: remove derivative dependency
  • Loading branch information
baszalmstra committed Aug 16, 2024

Verified

This commit was signed with the committer’s verified signature.
drashna Drashna Jaelre
commit b6648ca8920a9a8d1281ef185f99df7e6cfc441a
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
@@ -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"] }
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};

@@ -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<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> {
Loading
Oops, something went wrong.