diff --git a/radicle-git-ext/git-ref-format/core/src/cbor.rs b/radicle-git-ext/git-ref-format/core/src/cbor.rs index e01e46a..0df411b 100644 --- a/radicle-git-ext/git-ref-format/core/src/cbor.rs +++ b/radicle-git-ext/git-ref-format/core/src/cbor.rs @@ -24,7 +24,7 @@ impl<'de: 'a, 'a> Decode<'de> for &'a RefStr { } } -impl<'a> Encode for &'a RefStr { +impl Encode for &RefStr { #[inline] fn encode(&self, e: &mut Encoder) -> Result<(), encode::Error> { e.str(self.as_str())?; @@ -54,7 +54,7 @@ impl<'de: 'a, 'a> Decode<'de> for &'a PatternStr { } } -impl<'a> Encode for &'a PatternStr { +impl Encode for &PatternStr { #[inline] fn encode(&self, e: &mut Encoder) -> Result<(), encode::Error> { e.str(self.as_str())?; @@ -86,7 +86,7 @@ impl<'de: 'a, 'a> Decode<'de> for Qualified<'a> { } } -impl<'a> Encode for Qualified<'a> { +impl Encode for Qualified<'_> { #[inline] fn encode(&self, e: &mut Encoder) -> Result<(), encode::Error> { self.as_str().encode(e) @@ -103,7 +103,7 @@ impl<'de: 'a, 'a> Decode<'de> for Namespaced<'a> { } } -impl<'a> Encode for Namespaced<'a> { +impl Encode for Namespaced<'_> { #[inline] fn encode(&self, e: &mut Encoder) -> Result<(), encode::Error> { self.as_str().encode(e) diff --git a/radicle-git-ext/git-ref-format/core/src/name.rs b/radicle-git-ext/git-ref-format/core/src/name.rs index 933d558..6d8ddd5 100644 --- a/radicle-git-ext/git-ref-format/core/src/name.rs +++ b/radicle-git-ext/git-ref-format/core/src/name.rs @@ -213,7 +213,7 @@ impl AsRef for RefStr { } } -impl<'a> AsRef for &'a RefStr { +impl AsRef for &RefStr { #[inline] fn as_ref(&self) -> &RefStr { self diff --git a/radicle-git-ext/git-ref-format/core/src/name/iter.rs b/radicle-git-ext/git-ref-format/core/src/name/iter.rs index f24a6d0..3339107 100644 --- a/radicle-git-ext/git-ref-format/core/src/name/iter.rs +++ b/radicle-git-ext/git-ref-format/core/src/name/iter.rs @@ -34,7 +34,7 @@ impl<'a> Iterator for Components<'a> { } } -impl<'a> DoubleEndedIterator for Components<'a> { +impl DoubleEndedIterator for Components<'_> { #[inline] fn next_back(&mut self) -> Option { self.inner @@ -83,7 +83,7 @@ impl<'a> Component<'a> { } } -impl<'a> Deref for Component<'a> { +impl Deref for Component<'_> { type Target = RefStr; #[inline] diff --git a/radicle-git-ext/git-ref-format/core/src/refspec/iter.rs b/radicle-git-ext/git-ref-format/core/src/refspec/iter.rs index 09da0b7..9ea3747 100644 --- a/radicle-git-ext/git-ref-format/core/src/refspec/iter.rs +++ b/radicle-git-ext/git-ref-format/core/src/refspec/iter.rs @@ -66,7 +66,7 @@ impl<'a> Iterator for Components<'a> { } } -impl<'a> DoubleEndedIterator for Components<'a> { +impl DoubleEndedIterator for Components<'_> { #[inline] fn next_back(&mut self) -> Option { self.inner.next_back().map(|next| match next { diff --git a/radicle-git-ext/git-ref-format/core/src/serde.rs b/radicle-git-ext/git-ref-format/core/src/serde.rs index 5bead98..c5bac7f 100644 --- a/radicle-git-ext/git-ref-format/core/src/serde.rs +++ b/radicle-git-ext/git-ref-format/core/src/serde.rs @@ -23,7 +23,7 @@ impl<'de: 'a, 'a> Deserialize<'de> for &'a RefStr { } } -impl<'a> Serialize for &'a RefStr { +impl Serialize for &RefStr { #[inline] fn serialize(&self, serializer: S) -> Result where @@ -65,7 +65,7 @@ impl<'de: 'a, 'a> Deserialize<'de> for &'a PatternStr { } } -impl<'a> Serialize for &'a PatternStr { +impl Serialize for &PatternStr { #[inline] fn serialize(&self, serializer: S) -> Result where diff --git a/radicle-git-ext/src/blob.rs b/radicle-git-ext/src/blob.rs index 358d9b4..451d4f7 100644 --- a/radicle-git-ext/src/blob.rs +++ b/radicle-git-ext/src/blob.rs @@ -47,7 +47,7 @@ impl<'a> From<&'a str> for Branch<'a> { } } -impl<'a> From for Branch<'a> { +impl From for Branch<'_> { fn from(s: String) -> Self { Self::Name(Cow::Owned(s)) } diff --git a/radicle-git-ext/src/commit.rs b/radicle-git-ext/src/commit.rs index 95e6f2f..8d056b3 100644 --- a/radicle-git-ext/src/commit.rs +++ b/radicle-git-ext/src/commit.rs @@ -14,10 +14,8 @@ pub mod headers; pub mod trailers; -use std::{ - fmt::Write as _, - str::{self, FromStr}, -}; +use core::fmt; +use std::str::{self, FromStr}; use git2::{ObjectType, Oid}; @@ -139,7 +137,7 @@ impl CommitData { } /// Iterate over the [`Headers`] values that match the provided `name`. - pub fn values<'a>(&'a self, name: &'a str) -> impl Iterator + '_ { + pub fn values<'a>(&'a self, name: &'a str) -> impl Iterator + 'a { self.headers.values(name) } @@ -367,32 +365,28 @@ impl FromStr for Commit { } } -impl ToString for Commit { - fn to_string(&self) -> String { - let mut buf = String::new(); - - writeln!(buf, "tree {}", self.tree).ok(); - +impl fmt::Display for Commit { + fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result { + writeln!(f, "tree {}", self.tree)?; for parent in self.parents() { - writeln!(buf, "parent {parent}").ok(); + writeln!(f, "parent {parent}")?; } - - writeln!(buf, "author {}", self.author).ok(); - writeln!(buf, "committer {}", self.committer).ok(); + writeln!(f, "author {}", self.author)?; + writeln!(f, "committer {}", self.committer)?; for (name, value) in self.headers.iter() { - writeln!(buf, "{name} {}", value.replace('\n', "\n ")).ok(); + writeln!(f, "{name} {}", value.replace('\n', "\n "))?; } - writeln!(buf).ok(); - write!(buf, "{}", self.message.trim()).ok(); - writeln!(buf).ok(); + writeln!(f)?; + write!(f, "{}", self.message.trim())?; + writeln!(f)?; if !self.trailers.is_empty() { - writeln!(buf).ok(); + writeln!(f)?; } for trailer in self.trailers.iter() { - writeln!(buf, "{}", Trailer::from(trailer).display(": ")).ok(); + writeln!(f, "{}", Trailer::from(trailer).display(": "))?; } - buf + Ok(()) } } diff --git a/radicle-git-ext/src/commit/headers.rs b/radicle-git-ext/src/commit/headers.rs index cf9e10c..941b923 100644 --- a/radicle-git-ext/src/commit/headers.rs +++ b/radicle-git-ext/src/commit/headers.rs @@ -1,3 +1,4 @@ +use core::fmt; use std::borrow::Cow; const BEGIN_SSH: &str = "-----BEGIN SSH SIGNATURE-----\n"; @@ -30,17 +31,17 @@ impl<'a> Signature<'a> { } } -pub struct UnknownScheme; - -impl<'a> ToString for Signature<'a> { - fn to_string(&self) -> String { +impl fmt::Display for Signature<'_> { + fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result { match self { - Signature::Pgp(pgp) => pgp.to_string(), - Signature::Ssh(ssh) => ssh.to_string(), + Signature::Pgp(pgp) => f.write_str(pgp.as_ref()), + Signature::Ssh(ssh) => f.write_str(ssh.as_ref()), } } } +pub struct UnknownScheme; + impl Headers { pub fn new() -> Self { Headers(Vec::new()) @@ -50,7 +51,7 @@ impl Headers { self.0.iter().map(|(k, v)| (k.as_str(), v.as_str())) } - pub fn values<'a>(&'a self, name: &'a str) -> impl Iterator + '_ { + pub fn values<'a>(&'a self, name: &'a str) -> impl Iterator + 'a { self.iter() .filter_map(move |(k, v)| (k == name).then_some(v)) } diff --git a/radicle-git-ext/src/commit/trailers.rs b/radicle-git-ext/src/commit/trailers.rs index 00b4c42..74deb0b 100644 --- a/radicle-git-ext/src/commit/trailers.rs +++ b/radicle-git-ext/src/commit/trailers.rs @@ -148,7 +148,7 @@ pub struct Display<'a> { separator: &'a str, } -impl<'a> fmt::Display for Display<'a> { +impl fmt::Display for Display<'_> { fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { write!( f, diff --git a/radicle-git-ext/src/oid.rs b/radicle-git-ext/src/oid.rs index f2c4287..4e75b3c 100644 --- a/radicle-git-ext/src/oid.rs +++ b/radicle-git-ext/src/oid.rs @@ -35,7 +35,7 @@ mod serde_impls { { struct OidVisitor; - impl<'de> Visitor<'de> for OidVisitor { + impl Visitor<'_> for OidVisitor { type Value = Oid; fn expecting(&self, f: &mut fmt::Formatter) -> fmt::Result { diff --git a/radicle-surf/src/blob.rs b/radicle-surf/src/blob.rs index d8870f8..628f032 100644 --- a/radicle-surf/src/blob.rs +++ b/radicle-surf/src/blob.rs @@ -99,7 +99,7 @@ pub struct BlobRef<'a> { pub(crate) inner: git2::Blob<'a>, } -impl<'a> BlobRef<'a> { +impl BlobRef<'_> { pub fn id(&self) -> Oid { self.inner.id().into() } @@ -149,7 +149,7 @@ where } #[cfg(feature = "serde")] -impl<'a> Serialize for BlobRef<'a> { +impl Serialize for BlobRef<'_> { fn serialize(&self, serializer: S) -> Result where S: Serializer, diff --git a/radicle-surf/src/commit.rs b/radicle-surf/src/commit.rs index a4bc9f5..22bd2e3 100644 --- a/radicle-surf/src/commit.rs +++ b/radicle-surf/src/commit.rs @@ -113,7 +113,7 @@ impl std::fmt::Debug for Author { } } -impl<'repo> TryFrom> for Author { +impl TryFrom> for Author { type Error = str::Utf8Error; fn try_from(signature: git2::Signature) -> Result { @@ -182,7 +182,7 @@ impl Serialize for Commit { } } -impl<'repo> TryFrom> for Commit { +impl TryFrom> for Commit { type Error = Error; fn try_from(commit: git2::Commit) -> Result { diff --git a/radicle-surf/src/diff/git.rs b/radicle-surf/src/diff/git.rs index 4ecd004..6afe99b 100644 --- a/radicle-surf/src/diff/git.rs +++ b/radicle-surf/src/diff/git.rs @@ -99,7 +99,7 @@ pub mod error { } } -impl<'a> TryFrom> for DiffFile { +impl TryFrom> for DiffFile { type Error = error::FileMode; fn try_from(value: git2::DiffFile) -> Result { @@ -205,7 +205,7 @@ impl TryFrom> for DiffContent { } } -impl<'a> TryFrom> for Modification { +impl TryFrom> for Modification { type Error = error::Modification; fn try_from(line: git2::DiffLine) -> Result { @@ -228,7 +228,7 @@ impl From for Stats { } } -impl<'a> TryFrom> for Diff { +impl TryFrom> for Diff { type Error = error::Diff; fn try_from(git_diff: git2::Diff) -> Result { diff --git a/radicle-surf/src/history.rs b/radicle-surf/src/history.rs index b3af56d..82a1cb9 100644 --- a/radicle-surf/src/history.rs +++ b/radicle-surf/src/history.rs @@ -74,7 +74,7 @@ impl<'a> History<'a> { } } -impl<'a> Iterator for History<'a> { +impl Iterator for History<'_> { type Item = Result; fn next(&mut self) -> Option { @@ -108,7 +108,7 @@ impl<'a> Iterator for History<'a> { } } -impl<'a> std::fmt::Debug for History<'a> { +impl std::fmt::Debug for History<'_> { fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result { write!(f, "History of {}", self.head.id) } diff --git a/radicle-surf/src/refs.rs b/radicle-surf/src/refs.rs index 51b09c0..e0b9d71 100644 --- a/radicle-surf/src/refs.rs +++ b/radicle-surf/src/refs.rs @@ -32,7 +32,7 @@ impl<'a> Tags<'a> { } } -impl<'a> Iterator for Tags<'a> { +impl Iterator for Tags<'_> { type Item = Result; fn next(&mut self) -> Option { @@ -54,7 +54,7 @@ impl<'a> Iterator for Tags<'a> { } } -impl<'a> Iterator for TagNames<'a> { +impl Iterator for TagNames<'_> { type Item = Result, error::Tag>; fn next(&mut self) -> Option { @@ -99,7 +99,7 @@ impl<'a> Branches<'a> { } } -impl<'a> Iterator for Branches<'a> { +impl Iterator for Branches<'_> { type Item = Result; fn next(&mut self) -> Option { @@ -121,7 +121,7 @@ impl<'a> Iterator for Branches<'a> { } } -impl<'a> Iterator for BranchNames<'a> { +impl Iterator for BranchNames<'_> { type Item = Result, error::Branch>; fn next(&mut self) -> Option { @@ -177,7 +177,7 @@ impl<'a> Categories<'a> { } } -impl<'a> Iterator for Categories<'a> { +impl Iterator for Categories<'_> { type Item = Result<(RefString, RefString), error::Category>; fn next(&mut self) -> Option { diff --git a/radicle-surf/t/src/code_browsing.rs b/radicle-surf/t/src/code_browsing.rs index 6b0ecf8..3cafcde 100644 --- a/radicle-surf/t/src/code_browsing.rs +++ b/radicle-surf/t/src/code_browsing.rs @@ -58,7 +58,7 @@ fn browse_repo_lazily() { #[test] fn test_file_history() { let repo = Repository::open(GIT_PLATINUM).unwrap(); - let history = repo.history(&Branch::local(refname!("dev"))).unwrap(); + let history = repo.history(Branch::local(refname!("dev"))).unwrap(); let path = Path::new("README.md"); let mut file_history = history.by_path(&path); let commit = file_history.next().unwrap().unwrap(); diff --git a/radicle-surf/t/src/last_commit.rs b/radicle-surf/t/src/last_commit.rs index 2ab34a5..3bdf4ac 100644 --- a/radicle-surf/t/src/last_commit.rs +++ b/radicle-surf/t/src/last_commit.rs @@ -101,7 +101,7 @@ fn root() { .map(|commit| commit.id); let expected_oid = repo - .history(&Branch::local(refname!("master"))) + .history(Branch::local(refname!("master"))) .unwrap() .head() .id; @@ -112,7 +112,7 @@ fn root() { fn binary_file() { let repo = Repository::open(GIT_PLATINUM) .expect("Could not retrieve ./data/git-platinum as git repository"); - let history = repo.history(&Branch::local(refname!("dev"))).unwrap(); + let history = repo.history(Branch::local(refname!("dev"))).unwrap(); let file_commit = history.by_path(&"bin/cat").next(); assert!(file_commit.is_some()); println!("file commit: {:?}", &file_commit); diff --git a/radicle-surf/t/src/namespace.rs b/radicle-surf/t/src/namespace.rs index 6eefde1..0fe7b74 100644 --- a/radicle-surf/t/src/namespace.rs +++ b/radicle-surf/t/src/namespace.rs @@ -7,9 +7,9 @@ use super::GIT_PLATINUM; #[test] fn switch_to_banana() -> Result<(), Error> { let repo = Repository::open(GIT_PLATINUM)?; - let history_master = repo.history(&Branch::local(refname!("master")))?; + let history_master = repo.history(Branch::local(refname!("master")))?; repo.switch_namespace(&refname!("golden"))?; - let history_banana = repo.history(&Branch::local(refname!("banana")))?; + let history_banana = repo.history(Branch::local(refname!("banana")))?; assert_ne!(history_master.head(), history_banana.head()); @@ -19,14 +19,14 @@ fn switch_to_banana() -> Result<(), Error> { #[test] fn me_namespace() -> Result<(), Error> { let repo = Repository::open(GIT_PLATINUM)?; - let history = repo.history(&Branch::local(refname!("master")))?; + let history = repo.history(Branch::local(refname!("master")))?; assert_eq!(repo.which_namespace().unwrap(), None); repo.switch_namespace(&refname!("me"))?; assert_eq!(repo.which_namespace().unwrap(), Some("me".parse()?)); - let history_feature = repo.history(&Branch::local(refname!("feature/#1194")))?; + let history_feature = repo.history(Branch::local(refname!("feature/#1194")))?; assert_eq!(history.head(), history_feature.head()); let expected_branches: Vec = vec![Branch::local(refname!("feature/#1194"))]; @@ -54,7 +54,7 @@ fn me_namespace() -> Result<(), Error> { #[test] fn golden_namespace() -> Result<(), Error> { let repo = Repository::open(GIT_PLATINUM)?; - let history = repo.history(&Branch::local(refname!("master")))?; + let history = repo.history(Branch::local(refname!("master")))?; assert_eq!(repo.which_namespace().unwrap(), None); @@ -62,7 +62,7 @@ fn golden_namespace() -> Result<(), Error> { assert_eq!(repo.which_namespace().unwrap(), Some("golden".parse()?)); - let golden_history = repo.history(&Branch::local(refname!("master")))?; + let golden_history = repo.history(Branch::local(refname!("master")))?; assert_eq!(history.head(), golden_history.head()); let expected_branches: Vec = vec![ @@ -97,7 +97,7 @@ fn golden_namespace() -> Result<(), Error> { #[test] fn silver_namespace() -> Result<(), Error> { let repo = Repository::open(GIT_PLATINUM)?; - let history = repo.history(&Branch::local(refname!("master")))?; + let history = repo.history(Branch::local(refname!("master")))?; assert_eq!(repo.which_namespace().unwrap(), None); @@ -106,7 +106,7 @@ fn silver_namespace() -> Result<(), Error> { repo.which_namespace().unwrap(), Some("golden/silver".parse()?) ); - let silver_history = repo.history(&Branch::local(refname!("master")))?; + let silver_history = repo.history(Branch::local(refname!("master")))?; assert_ne!(history.head(), silver_history.head()); let expected_branches: Vec = vec![Branch::local(refname!("master"))]; diff --git a/radicle-surf/t/src/rev.rs b/radicle-surf/t/src/rev.rs index ff9799f..60294a0 100644 --- a/radicle-surf/t/src/rev.rs +++ b/radicle-surf/t/src/rev.rs @@ -19,7 +19,7 @@ use super::GIT_PLATINUM; #[test] fn _master() -> Result<(), Error> { let repo = Repository::open(GIT_PLATINUM)?; - let mut history = repo.history(&Branch::remote(component!("origin"), refname!("master")))?; + let mut history = repo.history(Branch::remote(component!("origin"), refname!("master")))?; let commit1 = Oid::from_str("3873745c8f6ffb45c990eb23b491d4b4b6182f95")?; assert!( diff --git a/rust-toolchain b/rust-toolchain index 9242d8e..40671b9 100644 --- a/rust-toolchain +++ b/rust-toolchain @@ -1 +1 @@ -1.76 +1.84