From 9f9c691b9d75371dc5a19c826be5f2ec9895b511 Mon Sep 17 00:00:00 2001 From: kiron1 Date: Sun, 31 Dec 2023 19:23:25 +0800 Subject: [PATCH] Fix clippy issues --- paclib/src/engine.rs | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/paclib/src/engine.rs b/paclib/src/engine.rs index c166ca22..0c26ae9d 100644 --- a/paclib/src/engine.rs +++ b/paclib/src/engine.rs @@ -109,7 +109,7 @@ impl<'a> Default for Engine<'a> { fn alert(_this: &JsValue, args: &[JsValue], _ctx: &mut Context) -> JsResult { // https://developer.mozilla.org/en-US/docs/Web/HTTP/Proxy_servers_and_tunneling/Proxy_Auto-Configuration_PAC_file#alert // https://developer.mozilla.org/en-US/docs/Web/API/Window/alert - if let Some(message) = args.get(0) { + if let Some(message) = args.first() { let message = message .as_string() .map(|s| s.to_std_string_escaped()) @@ -132,7 +132,7 @@ fn dns_resolve(_this: &JsValue, args: &[JsValue], ctx: &mut Context) -> JsResult .downcast_mut::() .expect("downcast_mut"); - let value = if let Some(host) = args.get(0) { + let value = if let Some(host) = args.first() { if let Ok(host) = host.to_string(ctx) { let resolved = dns_cache.lookup(&host.to_std_string_escaped()); match resolved { @@ -152,7 +152,7 @@ fn dns_resolve(_this: &JsValue, args: &[JsValue], ctx: &mut Context) -> JsResult fn my_ip_address(_this: &JsValue, _args: &[JsValue], _ctx: &mut Context) -> JsResult { let ip = default_net::get_default_interface() .ok() - .and_then(|i| i.ipv4.get(0).map(|i| i.addr.to_string())) + .and_then(|i| i.ipv4.first().map(|i| i.addr.to_string())) .unwrap_or_else(|| String::from("127.0.0.1")); Ok(JsValue::from(JsString::from(ip))) }