Deref RepoName to str
Lets a RepoName be passed anywhere a &str is expected without an
explicit as_str(), matching how String derefs to str.
Assisted-by: Claude Opus 4.8 via Claude Code
diff --git a/quire-server/src/bin/quire/commands/mirror.rs b/quire-server/src/bin/quire/commands/mirror.rs
index 4f8a678..5b1b945 100644
--- a/quire-server/src/bin/quire/commands/mirror.rs
+++ b/quire-server/src/bin/quire/commands/mirror.rs
@@ -8,7 +8,7 @@ use quire::quire::RepoName;
///
/// Exits non-zero if any mirror rejects the ref, even when others accept it.
pub async fn push(quire: &Quire, repo: &RepoName, ref_name: &str) -> Result<()> {
- let outcome = mirror::push_ref(quire, repo.as_str(), ref_name)?;
+ let outcome = mirror::push_ref(quire, repo, ref_name)?;
if outcome.pushed.is_empty() && outcome.failed.is_empty() {
println!("no mirrors configured for {repo}");
diff --git a/quire-server/src/bin/quire/commands/repo.rs b/quire-server/src/bin/quire/commands/repo.rs
index 78dabbe..a7a674e 100644
--- a/quire-server/src/bin/quire/commands/repo.rs
+++ b/quire-server/src/bin/quire/commands/repo.rs
@@ -36,7 +36,7 @@ pub async fn list(quire: &Quire) -> Result<()> {
}
pub async fn rm(quire: &Quire, name: &RepoName) -> Result<()> {
- let repo = quire.repo(name.as_str())?;
+ let repo = quire.repo(name)?;
fs_err::remove_dir_all(repo.path()).into_diagnostic()?;
diff --git a/quire-server/src/quire/mod.rs b/quire-server/src/quire/mod.rs
index 353a203..720ced4 100644
--- a/quire-server/src/quire/mod.rs
+++ b/quire-server/src/quire/mod.rs
@@ -78,6 +78,14 @@ impl RepoName {
}
}
+impl std::ops::Deref for RepoName {
+ type Target = str;
+
+ fn deref(&self) -> &str {
+ &self.0
+ }
+}
+
impl std::str::FromStr for RepoName {
type Err = RepoNameError;