mirror of
https://seed.radicle.dev/rad:z6cFWeWpnZNHh9rUW8phgA3b5yGt.git
synced 2026-11-28 21:50:27 +08:00
chore: update rust toolchain 1.84
Fixed clippy warnings for lifetime elision and preferring `Display` implementations over `ToString`.
This commit is contained in:
@@ -47,7 +47,7 @@ impl<'a> From<&'a str> for Branch<'a> {
|
||||
}
|
||||
}
|
||||
|
||||
impl<'a> From<String> for Branch<'a> {
|
||||
impl From<String> for Branch<'_> {
|
||||
fn from(s: String) -> Self {
|
||||
Self::Name(Cow::Owned(s))
|
||||
}
|
||||
|
||||
@@ -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<Tree, Parent> CommitData<Tree, Parent> {
|
||||
}
|
||||
|
||||
/// Iterate over the [`Headers`] values that match the provided `name`.
|
||||
pub fn values<'a>(&'a self, name: &'a str) -> impl Iterator<Item = &'a str> + '_ {
|
||||
pub fn values<'a>(&'a self, name: &'a str) -> impl Iterator<Item = &'a str> + '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(())
|
||||
}
|
||||
}
|
||||
|
||||
@@ -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<Item = &'a str> + '_ {
|
||||
pub fn values<'a>(&'a self, name: &'a str) -> impl Iterator<Item = &'a str> + 'a {
|
||||
self.iter()
|
||||
.filter_map(move |(k, v)| (k == name).then_some(v))
|
||||
}
|
||||
|
||||
@@ -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,
|
||||
|
||||
@@ -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 {
|
||||
|
||||
Reference in New Issue
Block a user