From 8de84b7ca32afd5037326025ed8fcfd06ed9db5f Mon Sep 17 00:00:00 2001 From: David Tolnay Date: Sat, 21 Oct 2023 22:00:59 -0700 Subject: [PATCH] Resolve get_first clippy lint warning: accessing first element with `variant.fields.get(0)` --> serde_derive/src/de.rs:1843:27 | 1843 | let default = variant.fields.get(0).map(|field| { | ^^^^^^^^^^^^^^^^^^^^^ help: try: `variant.fields.first()` | = help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#get_first = note: `-W clippy::get-first` implied by `-W clippy::all` = help: to override `-W clippy::all` add `#[allow(clippy::get_first)]` warning: accessing first element with `variant.fields.get(0)` --> serde_derive/src/de.rs:1888:27 | 1888 | let default = variant.fields.get(0).map(|field| { | ^^^^^^^^^^^^^^^^^^^^^ help: try: `variant.fields.first()` | = help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#get_first --- serde_derive/src/de.rs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/serde_derive/src/de.rs b/serde_derive/src/de.rs index 9942770a..e3b737c6 100644 --- a/serde_derive/src/de.rs +++ b/serde_derive/src/de.rs @@ -1840,7 +1840,7 @@ fn deserialize_internally_tagged_variant( let this_value = ¶ms.this_value; let type_name = params.type_name(); let variant_name = variant.ident.to_string(); - let default = variant.fields.get(0).map(|field| { + let default = variant.fields.first().map(|field| { let default = Expr(expr_is_missing(field, cattrs)); quote!((#default)) }); @@ -1885,7 +1885,7 @@ fn deserialize_untagged_variant( let this_value = ¶ms.this_value; let type_name = params.type_name(); let variant_name = variant.ident.to_string(); - let default = variant.fields.get(0).map(|field| { + let default = variant.fields.first().map(|field| { let default = Expr(expr_is_missing(field, cattrs)); quote!((#default)) });