Skip to content

Commit

Permalink
fix clippy issues
Browse files Browse the repository at this point in the history
  • Loading branch information
Ken Johnson committed Jun 18, 2024
1 parent ecbb863 commit 5d3ed28
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 16 deletions.
11 changes: 3 additions & 8 deletions src/component.rs
Original file line number Diff line number Diff line change
Expand Up @@ -23,8 +23,9 @@ pub type PackedComponents<'a> = (
Component<'a>,
);

#[derive(Debug, Clone, PartialEq, Eq, Hash)]
#[derive(Debug, Default, Clone, PartialEq, Eq, Hash)]
pub enum Component<'a> {
#[default]
Any,
NotApplicable,
Value(Cow<'a, str>),
Expand All @@ -48,12 +49,6 @@ impl fmt::Display for Component<'_> {
}
}

impl Default for Component<'_> {
fn default() -> Self {
Component::Any
}
}

impl<'a> Component<'a> {
pub fn new(val: &'a str) -> Self {
if val == "-" || val == "NA" {
Expand Down Expand Up @@ -136,7 +131,7 @@ impl From<&Component<'_>> for OwnedComponent {
match attribute {
Component::Any => Self::Any,
Component::NotApplicable => Self::NotApplicable,
Component::Value(value) => Self::Value((*value).to_owned().to_string()),
Component::Value(value) => Self::Value(value.clone().into_owned()),
}
}
}
Expand Down
9 changes: 2 additions & 7 deletions src/cpe.rs
Original file line number Diff line number Diff line change
Expand Up @@ -12,18 +12,13 @@ use std::str::FromStr;
/// CPE Language value
///
/// May be "ANY", or a valid RFC-5646 language tag.
#[derive(Debug, Clone, PartialEq, Eq, Hash)]
#[derive(Debug, Default, Clone, PartialEq, Eq, Hash)]
pub enum Language {
#[default]
Any,
Language(LanguageTag),
}

impl Default for Language {
fn default() -> Self {
Language::Any
}
}

impl FromStr for Language {
type Err = CpeError;
fn from_str(s: &str) -> Result<Self> {
Expand Down
2 changes: 1 addition & 1 deletion src/parse.rs
Original file line number Diff line number Diff line change
Expand Up @@ -111,7 +111,7 @@ pub fn parse_uri_attribute(value: &str) -> Result<Component> {
source,
value: value.to_owned(),
})?;
Cow::Owned((&*decoded).to_owned())
Cow::Owned((*decoded).to_owned())
} else {
percent_encoding::percent_decode_str(value)
.decode_utf8()
Expand Down

0 comments on commit 5d3ed28

Please sign in to comment.