From 41f05cacb2803852e57ea5a1caafe06cae5a7e70 Mon Sep 17 00:00:00 2001 From: Peter Cai Date: Mon, 5 Apr 2021 13:56:44 +0800 Subject: [PATCH] server: do not keep ownership of all options * We don't actually need all of the options; instead, move all the options to the respective structs and disown them immediately. --- src/server.rs | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/src/server.rs b/src/server.rs index 053c0d2..c16c035 100644 --- a/src/server.rs +++ b/src/server.rs @@ -52,18 +52,18 @@ pub struct ServerOptions { } pub struct Server { - options: ServerOptions, client: Client, + retries: usize, } impl Server { fn new(options: ServerOptions) -> Server { Server { client: Client::new( - options.upstream_urls.clone(), - OverrideResolver::new(options.overrides.clone(), options.override_ttl), + options.upstream_urls, + OverrideResolver::new(options.overrides, options.override_ttl), ), - options, + retries: options.retries, } } @@ -83,7 +83,7 @@ impl Server { let questions = err_response!(Self::extract_questions(body)); let records = err_response!( self.client - .query_with_retry(questions.clone(), self.options.retries) + .query_with_retry(questions.clone(), self.retries) .await ); let resp_format = Self::get_response_format(&req);