Skip to content

Commit 058fdec

Browse files
committed
Merge "Fix simple warning lints"
Pull-Request: #990 Signed-off-by: Yuki Kishimoto <[email protected]>
2 parents f2bad68 + 2eb8483 commit 058fdec

File tree

6 files changed

+13
-14
lines changed

6 files changed

+13
-14
lines changed

crates/nostr-relay-pool/src/relay/inner.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -430,7 +430,7 @@ impl InnerRelay {
430430
let subscriptions = self.atomic.subscriptions.read().await;
431431

432432
// No sleep if there are active subscriptions
433-
if subscriptions.len() > 0 {
433+
if !subscriptions.is_empty() {
434434
return false;
435435
}
436436

crates/nostr-relay-pool/src/relay/options.rs

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -359,16 +359,17 @@ mod tests {
359359
#[test]
360360
fn test_close() {
361361
let opts = SubscribeOptions::default();
362-
assert_eq!(opts.is_auto_closing(), false);
362+
assert!(!opts.is_auto_closing());
363363
let opts = SubscribeOptions::default().close_on(Some(SubscribeAutoCloseOptions::default()));
364-
assert_eq!(opts.is_auto_closing(), true);
364+
assert!(opts.is_auto_closing());
365365
}
366366

367367
#[test]
368368
fn test_sync_progress_percentage() {
369-
let mut sp = SyncProgress::default();
370-
sp.total = 5;
371-
sp.current = 2;
369+
let sp = SyncProgress {
370+
total: 5,
371+
current: 2,
372+
};
372373
assert_eq!(sp.percentage(), 2f64 / 5f64);
373374
let sp_zero = SyncProgress::default();
374375
assert_eq!(sp_zero.percentage(), 0.0);

crates/nostr/src/event/mod.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -339,7 +339,7 @@ struct EventIntermediate<'a> {
339339
pub created_at: Cow<'a, Timestamp>,
340340
pub kind: Cow<'a, Kind>,
341341
pub tags: Cow<'a, Tags>,
342-
pub content: Cow<'a, String>,
342+
pub content: Cow<'a, str>,
343343
pub sig: Cow<'a, Signature>,
344344
}
345345

crates/nostr/src/nips/nip06/bip32.rs

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -27,11 +27,9 @@ impl fmt::Display for Error {
2727
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
2828
match self {
2929
Self::Secp256k1(ref e) => write!(f, "{e}"),
30-
Self::InvalidChildNumber(ref n) => write!(
31-
f,
32-
"child number {} is invalid (not within [0, 2^31 - 1])",
33-
n
34-
),
30+
Self::InvalidChildNumber(ref n) => {
31+
write!(f, "child number {n} is invalid (not within [0, 2^31 - 1])")
32+
}
3533
}
3634
}
3735
}

crates/nostr/src/nips/nip44/v2.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -384,7 +384,7 @@ mod tests {
384384
for i in (0..len).step_by(2) {
385385
let high = val(hex[i], i);
386386
let low = val(hex[i + 1], i + 1);
387-
bytes.push(high << 4 | low);
387+
bytes.push((high << 4) | low);
388388
}
389389

390390
bytes

crates/nostr/src/util/hex.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@ impl fmt::Display for Error {
3131
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
3232
match self {
3333
Self::InvalidHexCharacter { c, index } => {
34-
write!(f, "Invalid character {} at position {}", c, index)
34+
write!(f, "Invalid character {c} at position {index}")
3535
}
3636
Self::OddLength => write!(f, "Odd number of digits"),
3737
Self::InvalidLength => write!(f, "Invalid length"),

0 commit comments

Comments
 (0)