From ef23eef31d199b5bef020b98c5644d07e67b0997 Mon Sep 17 00:00:00 2001 From: Glenn Griffin Date: Mon, 11 Nov 2019 09:41:30 -0800 Subject: [PATCH] Remove more unnecessary clones. --- src/authenticator_delegate.rs | 2 +- src/device.rs | 14 ++++++-------- 2 files changed, 7 insertions(+), 9 deletions(-) diff --git a/src/authenticator_delegate.rs b/src/authenticator_delegate.rs index f5bc4a9..eee7ec9 100644 --- a/src/authenticator_delegate.rs +++ b/src/authenticator_delegate.rs @@ -111,7 +111,7 @@ pub trait FlowDelegate: Send + Sync { /// Called if the request code is expired. You will have to start over in this case. /// This will be the last call the delegate receives. /// Given `DateTime` is the expiration date - fn expired(&self, _: &DateTime) {} + fn expired(&self, _: DateTime) {} /// Called if the user denied access. You would have to start over. /// This will be the last call the delegate receives. diff --git a/src/device.rs b/src/device.rs index 82e1aee..2c31af9 100644 --- a/src/device.rs +++ b/src/device.rs @@ -2,7 +2,7 @@ use std::pin::Pin; use std::time::Duration; use ::log::{error, log}; -use chrono::{self, Utc}; +use chrono::{DateTime, Utc}; use futures::prelude::*; use hyper; use hyper::header; @@ -144,14 +144,12 @@ where fd.present_user_code(&pollinf); let maxn = wait.as_secs() / pollinf.interval.as_secs(); for _ in 0..maxn { - let fd = fd.clone(); - let pollinf = pollinf.clone(); tokio::timer::delay_for(pollinf.interval).await; let r = Self::poll_token( application_secret, client.clone(), &device_code, - pollinf.clone(), + pollinf.expires_at, fd, ) .await; @@ -269,12 +267,12 @@ where application_secret: &ApplicationSecret, client: hyper::Client, device_code: &str, - pi: PollInformation, + expires_at: DateTime, fd: &FD, ) -> Result, PollError> { - if pi.expires_at <= Utc::now() { - fd.expired(&pi.expires_at); - return Err(PollError::Expired(pi.expires_at)); + if expires_at <= Utc::now() { + fd.expired(expires_at); + return Err(PollError::Expired(expires_at)); } // We should be ready for a new request