From a1d6b5e3f72126821ca37f0ef097fa0120106777 Mon Sep 17 00:00:00 2001 From: DaniPopes <57450786+DaniPopes@users.noreply.github.com> Date: Thu, 12 Jan 2023 04:05:39 +0100 Subject: [PATCH] chore: clippy (#2032) --- ethers-providers/src/transports/common.rs | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/ethers-providers/src/transports/common.rs b/ethers-providers/src/transports/common.rs index 747e1405..a23b68d5 100644 --- a/ethers-providers/src/transports/common.rs +++ b/ethers-providers/src/transports/common.rs @@ -1,5 +1,6 @@ // Code adapted from: https://github.com/althea-net/guac_rs/tree/master/web3/src/jsonrpc +use base64::{engine::general_purpose, Engine}; use ethers_core::types::U256; use serde::{ de::{self, MapAccess, Unexpected, Visitor}, @@ -190,8 +191,10 @@ pub enum Authorization { } impl Authorization { - pub fn basic(username: impl Into, password: impl Into) -> Self { - let auth_secret = base64::encode(username.into() + ":" + &password.into()); + pub fn basic(username: impl AsRef, password: impl AsRef) -> Self { + let username = username.as_ref(); + let password = password.as_ref(); + let auth_secret = general_purpose::STANDARD.encode(format!("{username}:{password}")); Self::Basic(auth_secret) }