Fixes clippy issues

Clippy is complaining about using `.get(0)` instead of `.fist()` in methods
where we are getting more than just the first item. Suppress those warning.

Also fixes some actual issues.
This commit is contained in:
Sergi Delgado Segura 2024-01-08 13:38:59 -05:00
parent a4accedfee
commit e6495c31aa
No known key found for this signature in database
GPG key ID: 35DDB7126CCB7618
3 changed files with 6 additions and 2 deletions

View file

@ -276,7 +276,7 @@ mod tests {
// last_n_blocks is ordered from latest to earliest
let first_block = last_n_blocks.get(cache_size - 1).unwrap();
let last_block = last_n_blocks.get(0).unwrap();
let last_block = last_n_blocks.first().unwrap();
let mid = last_n_blocks.get(cache_size / 2).unwrap();
let cache: TxIndex<Locator, Transaction> = TxIndex::new(&last_n_blocks, height as u32);

View file

@ -1163,7 +1163,7 @@ mod tests {
let mut uuids = HashSet::new();
// Let the watcher track these breaches.
for (_, (_, tx)) in breaches.iter().enumerate() {
for tx in breaches.values() {
let (uuid, appointment) =
generate_dummy_appointment_with_user(user_id, Some(&tx.txid()));
let appointment = appointment.inner;

View file

@ -94,6 +94,8 @@ impl RegisterParams {
impl TryFrom<serde_json::Value> for RegisterParams {
type Error = RegisterError;
// clippy-fix: We are getting more than just the first item, so this clippy check does not make sense here
#[allow(clippy::get_first)]
fn try_from(value: serde_json::Value) -> Result<Self, Self::Error> {
match value {
serde_json::Value::String(s) => {
@ -193,6 +195,8 @@ pub struct GetAppointmentParams {
impl TryFrom<serde_json::Value> for GetAppointmentParams {
type Error = GetAppointmentError;
// clippy-fix: We are getting more than just the first item, so this clippy check does not make sense here
#[allow(clippy::get_first)]
fn try_from(value: serde_json::Value) -> Result<Self, Self::Error> {
match value {
serde_json::Value::Array(a) => {