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

chore: add Borrow impl for Extra and NormalizedPackageName #89

Merged
merged 1 commit into from
Nov 24, 2023
Merged
Show file tree
Hide file tree
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
7 changes: 7 additions & 0 deletions crates/rattler_installs_packages/src/extra.rs
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@
use miette::Diagnostic;
use serde::{Serialize, Serializer};
use serde_with::DeserializeFromStr;
use std::borrow::Borrow;
use std::cmp::Ordering;
use std::hash::{Hash, Hasher};
use std::str::FromStr;
Expand Down Expand Up @@ -110,3 +111,9 @@ impl Serialize for Extra {
self.source.as_ref().serialize(serializer)
}
}

impl Borrow<str> for Extra {
fn borrow(&self) -> &str {
self.normalized.as_ref()
}
}
7 changes: 7 additions & 0 deletions crates/rattler_installs_packages/src/package_name.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ use miette::Diagnostic;
use regex::Regex;
use serde::{Serialize, Serializer};
use serde_with::{DeserializeFromStr, SerializeDisplay};
use std::borrow::Borrow;
use std::cmp::Ordering;
use std::fmt::{Display, Formatter};
use std::hash::{Hash, Hasher};
Expand Down Expand Up @@ -145,6 +146,12 @@ impl FromStr for NormalizedPackageName {
}
}

impl Borrow<str> for NormalizedPackageName {
fn borrow(&self) -> &str {
self.0.as_ref()
}
}

#[cfg(test)]
mod test {
use super::*;
Expand Down