clippy fixes

Signed-off-by: William Casarin <jb55@jb55.com>
This commit is contained in:
William Casarin
2025-07-17 13:49:53 -07:00
parent a4c1b38116
commit 8a1398face
26 changed files with 51 additions and 62 deletions

View File

@@ -15,9 +15,9 @@ pub fn hybrid_contacts_filter(
add_pk: Option<&[u8; 32]>,
with_hashtags: bool,
) -> Result<HybridFilter, Error> {
let local = filter::filter_from_tags(&note, add_pk, with_hashtags)?
let local = filter::filter_from_tags(note, add_pk, with_hashtags)?
.into_filter([1], filter::default_limit());
let remote = filter::filter_from_tags(&note, add_pk, with_hashtags)?
let remote = filter::filter_from_tags(note, add_pk, with_hashtags)?
.into_filter([1, 0], filter::default_remote_limit());
Ok(HybridFilter::split(local, remote))

View File

@@ -235,7 +235,7 @@ impl HybridFilter {
Self::Split(split) => &split.local,
// local as the same as remote in unsplit
Self::Unsplit(local) => &local,
Self::Unsplit(local) => local,
}
}

View File

@@ -163,11 +163,11 @@ const KB: usize = 1024;
fn byte_to_string(b: usize) -> String {
if b >= MB {
let mbs = b as f32 / MB as f32;
format!("{:.2} MB", mbs)
format!("{mbs:.2} MB")
} else if b >= KB {
let kbs = b as f32 / KB as f32;
format!("{:.2} KB", kbs)
format!("{kbs:.2} KB")
} else {
format!("{} B", b)
format!("{b} B")
}
}

View File

@@ -55,7 +55,7 @@ impl fmt::Display for RelaySpec {
// add the read and write markers if present
impl fmt::Debug for RelaySpec {
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
write!(f, "\"{}\"", self)?;
write!(f, "\"{self}\"")?;
if self.has_read_marker {
write!(f, " [r]")?;
}

View File

@@ -107,7 +107,7 @@ impl Directory {
} else {
Err(Error::Io(io::Error::new(
io::ErrorKind::NotFound,
format!("Requested file was not found: {}", file_name),
format!("Requested file was not found: {file_name}"),
)))
}
}
@@ -142,8 +142,7 @@ impl Directory {
})
} else {
Err(Error::Generic(format!(
"Requested file was not found: {}",
file_name
"Requested file was not found: {file_name}"
)))
}
}
@@ -197,8 +196,7 @@ pub fn delete_file(directory: &Path, file_name: String) -> Result<()> {
fs::remove_file(file_to_delete).map_err(Error::Io)
} else {
Err(Error::Generic(format!(
"Requested file to delete was not found: {}",
file_name
"Requested file to delete was not found: {file_name}"
)))
}
}

View File

@@ -18,37 +18,37 @@ pub fn time_ago_since(timestamp: u64) -> String {
let years = duration / 31_536_000; // seconds in a year
if years >= 1 {
return format!("{}{}yr", relstr, years);
return format!("{relstr}{years}yr");
}
let months = duration / 2_592_000; // seconds in a month (30.44 days)
if months >= 1 {
return format!("{}{}mth", relstr, months);
return format!("{relstr}{months}mth");
}
let weeks = duration / 604_800; // seconds in a week
if weeks >= 1 {
return format!("{}{}wk", relstr, weeks);
return format!("{relstr}{weeks}wk");
}
let days = duration / 86_400; // seconds in a day
if days >= 1 {
return format!("{}{}d", relstr, days);
return format!("{relstr}{days}d");
}
let hours = duration / 3600; // seconds in an hour
if hours >= 1 {
return format!("{}{}h", relstr, hours);
return format!("{relstr}{hours}h");
}
let minutes = duration / 60; // seconds in a minute
if minutes >= 1 {
return format!("{}{}m", relstr, minutes);
return format!("{relstr}{minutes}m");
}
let seconds = duration;
if seconds >= 3 {
return format!("{}{}s", relstr, seconds);
return format!("{relstr}{seconds}s");
}
"now".to_string()

View File

@@ -467,15 +467,15 @@ pub enum ZappingError {
impl std::fmt::Display for ZappingError {
fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
match self {
ZappingError::InvoiceFetchFailed(err) => write!(f, "Failed to fetch invoice: {}", err),
ZappingError::InvoiceFetchFailed(err) => write!(f, "Failed to fetch invoice: {err}"),
ZappingError::InvalidAccount => write!(f, "Invalid account"),
ZappingError::UnsupportedOperation => {
write!(f, "Unsupported operation (e.g. profile zaps)")
}
ZappingError::InvalidZapAddress => write!(f, "Invalid zap address"),
ZappingError::SenderNoWallet => write!(f, "Sender has no wallet"),
ZappingError::InvalidNWCResponse(msg) => write!(f, "Invalid NWC response: {}", msg),
ZappingError::FutureError(msg) => write!(f, "Future error: {}", msg),
ZappingError::InvalidNWCResponse(msg) => write!(f, "Invalid NWC response: {msg}"),
ZappingError::FutureError(msg) => write!(f, "Future error: {msg}"),
}
}
}