clippy: fix lint errors

Signed-off-by: William Casarin <jb55@jb55.com>
This commit is contained in:
William Casarin
2025-08-19 09:45:36 -07:00
parent 9ef72ec7de
commit 3aa4d00053
18 changed files with 25 additions and 24 deletions

View File

@@ -68,7 +68,7 @@ impl From<RelayEvent<'_>> for OwnedRelayEvent {
} }
#[derive(PartialEq, Eq, Hash, Clone)] #[derive(PartialEq, Eq, Hash, Clone)]
pub struct RelaySub { pub struct _RelaySub {
pub(crate) subid: String, pub(crate) subid: String,
pub(crate) filter: String, pub(crate) filter: String,
} }

View File

@@ -42,7 +42,7 @@ impl Contacts {
pub(super) fn query(&mut self, ndb: &Ndb, txn: &Transaction) { pub(super) fn query(&mut self, ndb: &Ndb, txn: &Transaction) {
let binding = ndb let binding = ndb
.query(txn, &[self.filter.clone()], 1) .query(txn, std::slice::from_ref(&self.filter), 1)
.expect("query user relays results"); .expect("query user relays results");
let Some(res) = binding.first() else { let Some(res) = binding.first() else {

View File

@@ -33,7 +33,7 @@ impl AccountMutedData {
.limit() .limit()
.unwrap_or(crate::filter::default_limit()) as i32; .unwrap_or(crate::filter::default_limit()) as i32;
let nks = ndb let nks = ndb
.query(txn, &[self.filter.clone()], lim) .query(txn, std::slice::from_ref(&self.filter), lim)
.expect("query user muted results") .expect("query user muted results")
.iter() .iter()
.map(|qr| qr.note_key) .map(|qr| qr.note_key)

View File

@@ -36,7 +36,7 @@ impl AccountRelayData {
.limit() .limit()
.unwrap_or(crate::filter::default_limit()) as i32; .unwrap_or(crate::filter::default_limit()) as i32;
let nks = ndb let nks = ndb
.query(txn, &[self.filter.clone()], lim) .query(txn, std::slice::from_ref(&self.filter), lim)
.expect("query user relays results") .expect("query user relays results")
.iter() .iter()
.map(|qr| qr.note_key) .map(|qr| qr.note_key)

View File

@@ -241,8 +241,8 @@ impl Notedeck {
let setting_locale: Result<LanguageIdentifier, LanguageIdentifierError> = let setting_locale: Result<LanguageIdentifier, LanguageIdentifierError> =
settings.locale().parse(); settings.locale().parse();
if setting_locale.is_ok() { if let Ok(setting_locale) = setting_locale {
if let Err(err) = i18n.set_locale(setting_locale.unwrap()) { if let Err(err) = i18n.set_locale(setting_locale) {
error!("{err}"); error!("{err}");
} }
} }

View File

@@ -35,7 +35,7 @@ impl TexturesCache {
&mut self, &mut self,
url: &str, url: &str,
closure: impl FnOnce() -> Promise<Option<Result<TexturedImage>>>, closure: impl FnOnce() -> Promise<Option<Result<TexturedImage>>>,
) -> LoadableTextureState { ) -> LoadableTextureState<'_> {
let internal = self.handle_and_get_state_internal(url, true, closure); let internal = self.handle_and_get_state_internal(url, true, closure);
internal.into() internal.into()
@@ -45,7 +45,7 @@ impl TexturesCache {
&mut self, &mut self,
url: &str, url: &str,
closure: impl FnOnce() -> Promise<Option<Result<TexturedImage>>>, closure: impl FnOnce() -> Promise<Option<Result<TexturedImage>>>,
) -> TextureState { ) -> TextureState<'_> {
let internal = self.handle_and_get_state_internal(url, false, closure); let internal = self.handle_and_get_state_internal(url, false, closure);
internal.into() internal.into()
@@ -96,7 +96,7 @@ impl TexturesCache {
}); });
} }
pub fn get_and_handle(&mut self, url: &str) -> Option<LoadableTextureState> { pub fn get_and_handle(&mut self, url: &str) -> Option<LoadableTextureState<'_>> {
self.cache.get_mut(url).map(|state| { self.cache.get_mut(url).map(|state| {
handle_occupied(state, true); handle_occupied(state, true);
state.into() state.into()

View File

@@ -77,6 +77,7 @@ impl PartialEq for RelaySpec {
impl Eq for RelaySpec {} impl Eq for RelaySpec {}
#[allow(clippy::non_canonical_partial_ord_impl)]
impl PartialOrd for RelaySpec { impl PartialOrd for RelaySpec {
fn partial_cmp(&self, other: &Self) -> Option<Ordering> { fn partial_cmp(&self, other: &Self) -> Option<Ordering> {
Some(self.url.cmp(&other.url)) Some(self.url.cmp(&other.url))

View File

@@ -22,7 +22,7 @@ impl UserAccount {
} }
} }
pub fn keypair(&self) -> KeypairUnowned { pub fn keypair(&self) -> KeypairUnowned<'_> {
KeypairUnowned { KeypairUnowned {
pubkey: &self.key.pubkey, pubkey: &self.key.pubkey,
secret_key: self.key.secret_key.as_ref(), secret_key: self.key.secret_key.as_ref(),

View File

@@ -48,7 +48,7 @@ impl<T, E> LoadingState<T, E> {
} }
#[derive(Serialize, Debug, Clone)] #[derive(Serialize, Debug, Clone)]
pub struct WaitRequest { pub struct _WaitRequest {
pub indexname: String, pub indexname: String,
pub subsystem: String, pub subsystem: String,
pub nextvalue: u64, pub nextvalue: u64,

View File

@@ -190,7 +190,7 @@ impl DecksCache {
&self.fallback_pubkey &self.fallback_pubkey
} }
pub fn get_all_decks_mut(&mut self) -> ValuesMut<Pubkey, Decks> { pub fn get_all_decks_mut(&mut self) -> ValuesMut<'_, Pubkey, Decks> {
self.account_to_decks.values_mut() self.account_to_decks.values_mut()
} }

View File

@@ -75,7 +75,7 @@ pub fn get_nostr_build_upload_url() -> Promise<Result<String, Error>> {
get_upload_url_from_provider(NOSTR_BUILD_URL()) get_upload_url_from_provider(NOSTR_BUILD_URL())
} }
fn create_nip98_note(seckey: &[u8; 32], upload_url: String, payload_hash: String) -> Note { fn create_nip98_note(seckey: &[u8; 32], upload_url: String, payload_hash: String) -> Note<'_> {
NoteBuilder::new() NoteBuilder::new()
.kind(27235) .kind(27235)
.start_tag() .start_tag()

View File

@@ -960,7 +960,7 @@ pub fn render_nav(
ctx.ndb, ctx.ndb,
ctx.img_cache, ctx.img_cache,
get_active_columns_mut(ctx.i18n, ctx.accounts, &mut app.decks_cache), get_active_columns_mut(ctx.i18n, ctx.accounts, &mut app.decks_cache),
&[route.clone()], std::slice::from_ref(route),
col, col,
ctx.i18n, ctx.i18n,
) )

View File

@@ -56,7 +56,7 @@ impl NewPost {
} }
} }
pub fn to_note(&self, seckey: &[u8; 32]) -> Note { pub fn to_note(&self, seckey: &[u8; 32]) -> Note<'_> {
let mut content = self.content.clone(); let mut content = self.content.clone();
append_urls(&mut content, &self.media); append_urls(&mut content, &self.media);
@@ -77,7 +77,7 @@ impl NewPost {
builder.sign(seckey).build().expect("note should be ok") builder.sign(seckey).build().expect("note should be ok")
} }
pub fn to_reply(&self, seckey: &[u8; 32], replying_to: &Note) -> Note { pub fn to_reply(&self, seckey: &[u8; 32], replying_to: &Note) -> Note<'_> {
let mut content = self.content.clone(); let mut content = self.content.clone();
append_urls(&mut content, &self.media); append_urls(&mut content, &self.media);
@@ -157,7 +157,7 @@ impl NewPost {
.expect("expected build to work") .expect("expected build to work")
} }
pub fn to_quote(&self, seckey: &[u8; 32], quoting: &Note) -> Note { pub fn to_quote(&self, seckey: &[u8; 32], quoting: &Note) -> Note<'_> {
let mut new_content = format!( let mut new_content = format!(
"{}\nnostr:{}", "{}\nnostr:{}",
self.content, self.content,

View File

@@ -15,7 +15,7 @@ impl SaveProfileChanges {
pub fn new(kp: FullKeypair, state: ProfileState) -> Self { pub fn new(kp: FullKeypair, state: ProfileState) -> Self {
Self { kp, state } Self { kp, state }
} }
pub fn to_note(&self) -> Note { pub fn to_note(&self) -> Note<'_> {
let sec = &self.kp.secret_key.to_secret_bytes(); let sec = &self.kp.secret_key.to_secret_bytes();
add_client_tag(NoteBuilder::new()) add_client_tag(NoteBuilder::new())
.kind(0) .kind(0)

View File

@@ -532,7 +532,7 @@ impl TimelineKind {
let contact_filter = contacts_filter(pk.bytes()); let contact_filter = contacts_filter(pk.bytes());
let results = ndb let results = ndb
.query(txn, &[contact_filter.clone()], 1) .query(txn, std::slice::from_ref(&contact_filter), 1)
.expect("contact query failed?"); .expect("contact query failed?");
let kind_fn = TimelineKind::last_per_pubkey; let kind_fn = TimelineKind::last_per_pubkey;
@@ -681,7 +681,7 @@ fn contact_filter_state(txn: &Transaction, ndb: &Ndb, pk: &Pubkey) -> FilterStat
let contact_filter = contacts_filter(pk); let contact_filter = contacts_filter(pk);
let results = ndb let results = ndb
.query(txn, &[contact_filter.clone()], 1) .query(txn, std::slice::from_ref(&contact_filter), 1)
.expect("contact query failed?"); .expect("contact query failed?");
if results.is_empty() { if results.is_empty() {
@@ -706,7 +706,7 @@ fn last_per_pubkey_filter_state(ndb: &Ndb, pk: &Pubkey) -> FilterState {
let txn = Transaction::new(ndb).expect("txn"); let txn = Transaction::new(ndb).expect("txn");
let results = ndb let results = ndb
.query(&txn, &[contact_filter.clone()], 1) .query(&txn, std::slice::from_ref(&contact_filter), 1)
.expect("contact query failed?"); .expect("contact query failed?");
if results.is_empty() { if results.is_empty() {

View File

@@ -274,7 +274,7 @@ struct RelayInfo<'a> {
pub status: RelayStatus, pub status: RelayStatus,
} }
fn get_relay_infos(pool: &RelayPool) -> Vec<RelayInfo> { fn get_relay_infos(pool: &RelayPool) -> Vec<RelayInfo<'_>> {
pool.relays pool.relays
.iter() .iter()
.map(|relay| RelayInfo { .map(|relay| RelayInfo {

View File

@@ -30,7 +30,7 @@ pub enum DefaultZapState<'a> {
Valid(&'a Msats), // in milisats Valid(&'a Msats), // in milisats
} }
pub fn get_default_zap_state(default_zap: &mut DefaultZapMsats) -> DefaultZapState { pub fn get_default_zap_state(default_zap: &mut DefaultZapMsats) -> DefaultZapState<'_> {
if default_zap.pending.is_rewriting { if default_zap.pending.is_rewriting {
return DefaultZapState::Pending(&mut default_zap.pending); return DefaultZapState::Pending(&mut default_zap.pending);
} }

View File

@@ -781,7 +781,7 @@ impl<'a> ScaledTexture<'a> {
} }
} }
pub fn get_image(&self) -> Image { pub fn get_image(&self) -> Image<'_> {
texture_to_image(self.tex, self.size).fit_to_exact_size(self.scaled_size) texture_to_image(self.tex, self.size).fit_to_exact_size(self.scaled_size)
} }
} }