Skip to content

Commit 6c8d2b1

Browse files
committed
fix: clippy complaints in the code
1 parent 88e8e48 commit 6c8d2b1

File tree

4 files changed

+15
-17
lines changed

4 files changed

+15
-17
lines changed

eventually-postgres/src/lib.rs

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -13,15 +13,15 @@ pub mod event;
1313

1414
pub(crate) static MIGRATIONS: sqlx::migrate::Migrator = sqlx::migrate!("./migrations");
1515

16+
use std::sync::LazyLock;
17+
1618
use eventually::version::{ConflictError, Version};
17-
use lazy_static::lazy_static;
1819
use regex::Regex;
1920

20-
lazy_static! {
21-
static ref CONFLICT_ERROR_REGEX: Regex =
22-
Regex::new(r"version check failed, expected: (?P<expected>\d), got: (?P<got>\d)")
23-
.expect("regex compiles successfully");
24-
}
21+
static CONFLICT_ERROR_REGEX: LazyLock<Regex> = LazyLock::new(|| {
22+
Regex::new(r"version check failed, expected: (?P<expected>\d), got: (?P<got>\d)")
23+
.expect("regex compiles successfully")
24+
});
2525

2626
pub(crate) fn check_for_conflict_error(err: &sqlx::Error) -> Option<ConflictError> {
2727
fn capture_to_version(captures: &regex::Captures, name: &'static str) -> Version {

eventually/src/event/store.rs

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -343,8 +343,9 @@ where
343343
#[allow(clippy::semicolon_if_nothing_returned)] // False positives :shrugs:
344344
#[cfg(test)]
345345
mod test {
346+
use std::sync::LazyLock;
347+
346348
use futures::TryStreamExt;
347-
use lazy_static::lazy_static;
348349

349350
use super::*;
350351
use crate::event;
@@ -354,13 +355,13 @@ mod test {
354355

355356
const STREAM_ID: &str = "stream:test";
356357

357-
lazy_static! {
358-
static ref EVENTS: Vec<event::Envelope<StringMessage>> = vec![
358+
static EVENTS: LazyLock<Vec<event::Envelope<StringMessage>>> = LazyLock::new(|| {
359+
vec![
359360
event::Envelope::from(StringMessage("event-1")),
360361
event::Envelope::from(StringMessage("event-2")),
361362
event::Envelope::from(StringMessage("event-3")),
362-
];
363-
}
363+
]
364+
});
364365

365366
#[tokio::test]
366367
async fn it_works() {

examples/Cargo.toml

Lines changed: 0 additions & 3 deletions
This file was deleted.

examples/bank-accounting/src/domain.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -59,7 +59,7 @@ impl Message for BankAccountEvent {
5959
BankAccountEvent::TransferWasReceived { .. } => "BankAccountTransferWasReceived",
6060
BankAccountEvent::TransferWasDeclined { .. } => "BankAccountTransferWasDeclined",
6161
BankAccountEvent::TransferWasConfirmed { .. } => "BankAccountTransferWasConfirmed",
62-
BankAccountEvent::WasClosed { .. } => "BankAccountWasClosed",
62+
BankAccountEvent::WasClosed => "BankAccountWasClosed",
6363
BankAccountEvent::WasReopened { .. } => "BankAccountWasReopened",
6464
}
6565
}
@@ -233,7 +233,7 @@ impl BankAccountRoot {
233233
return Err(BankAccountError::InsufficientFunds);
234234
}
235235

236-
let transaction_already_pending = self.pending_transactions.get(&transaction.id).is_some();
236+
let transaction_already_pending = self.pending_transactions.contains_key(&transaction.id);
237237
if transaction_already_pending {
238238
return Ok(());
239239
}
@@ -275,7 +275,7 @@ impl BankAccountRoot {
275275
&mut self,
276276
transaction_id: TransactionId,
277277
) -> Result<(), BankAccountError> {
278-
let is_transaction_recorded = self.pending_transactions.get(&transaction_id).is_some();
278+
let is_transaction_recorded = self.pending_transactions.contains_key(&transaction_id);
279279
if !is_transaction_recorded {
280280
// TODO: return error
281281
}

0 commit comments

Comments
 (0)