Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

remove needless pass by value #61

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion examples/sweeping.rs
Original file line number Diff line number Diff line change
Expand Up @@ -105,7 +105,7 @@ async fn run() -> anyhow::Result<()> {
&merchant_account.id,
&SetupSweepingRequest {
max_amount_in_minor: amount,
currency: merchant_account.currency.clone(),
currency: merchant_account.currency,
frequency: frequency.clone(),
},
)
Expand Down
2 changes: 1 addition & 1 deletion src/apis/payments/model.rs
Original file line number Diff line number Diff line change
Expand Up @@ -123,7 +123,7 @@ pub enum PaymentStatus {
},
}

#[derive(Serialize, Deserialize, Debug, Clone, Eq, PartialEq, Hash)]
#[derive(Serialize, Deserialize, Debug, Clone, Copy, Eq, PartialEq, Hash)]
#[serde(rename_all = "UPPERCASE")]
pub enum Currency {
Gbp,
Expand Down
8 changes: 3 additions & 5 deletions src/authenticator.rs
Original file line number Diff line number Diff line change
Expand Up @@ -17,10 +17,11 @@ pub struct Authenticator {
impl Authenticator {
/// Starts a new authenticator with the given initial credentials.
pub fn new(client: ClientWithMiddleware, auth_url: Url, credentials: Credentials) -> Self {
let client_id = credentials.client_id().to_string();
let state = AuthenticatorState {
client,
auth_url,
credentials: credentials.clone(),
credentials,
access_token: None,
};

Expand All @@ -36,10 +37,7 @@ impl Authenticator {
process_loop(state, rx).await;
});

Self {
tx,
client_id: credentials.client_id().into(),
}
Self { tx, client_id }
}

/// Returns the current access token used for authentication against the TrueLayer APIs.
Expand Down
1 change: 1 addition & 0 deletions src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -137,6 +137,7 @@
//! ```

#![deny(missing_debug_implementations)]
#![warn(clippy::needless_pass_by_value)]
#![forbid(unsafe_code)]

pub mod apis;
Expand Down
4 changes: 2 additions & 2 deletions tests/common/mock_server/routes.rs
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,7 @@ pub(super) async fn create_payment(
Payment {
id: id.clone(),
amount_in_minor: create_payment_request.amount_in_minor,
currency: create_payment_request.currency.clone(),
currency: create_payment_request.currency,
user: user.clone(),
payment_method: create_payment_request.payment_method.clone(),
created_at: Utc::now(),
Expand Down Expand Up @@ -544,7 +544,7 @@ pub(super) async fn create_payout(
id: payout_id.clone(),
merchant_account_id: request.merchant_account_id.clone(),
amount_in_minor: request.amount_in_minor,
currency: request.currency.clone(),
currency: request.currency,
beneficiary: request.beneficiary.clone(),
created_at: Utc::now(),
status: PayoutStatus::Pending,
Expand Down
2 changes: 1 addition & 1 deletion tests/integration_tests/payments.rs
Original file line number Diff line number Diff line change
Expand Up @@ -179,7 +179,7 @@ impl CreatePaymentScenario {
// Create a payment
let create_payment_request = CreatePaymentRequest {
amount_in_minor: 1,
currency: self.currency.clone(),
currency: self.currency,
payment_method: PaymentMethod::BankTransfer {
provider_selection,
beneficiary: match self.beneficiary {
Expand Down