Skip to content

Commit

Permalink
chore: switch to matches macro
Browse files Browse the repository at this point in the history
  • Loading branch information
avhz authored and avhz committed Nov 19, 2024
1 parent 94d96cd commit 16a8bd7
Show file tree
Hide file tree
Showing 7 changed files with 26 additions and 31 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/cargo_build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -25,4 +25,4 @@ jobs:
# BUILD THE LIBRARY
# ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
- name: Build RustQuant.
run: cargo build --release --verbose --all-features
run: cargo build --release --verbose --all-features --all-targets
2 changes: 1 addition & 1 deletion .github/workflows/cargo_test_doctests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -26,4 +26,4 @@ jobs:
# TEST THE LIBRARY
# ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
- name: Run doc tests.
run: cargo test --doc # --verbose
run: cargo test --doc --verbose --all-features --all-targets --no-fail-fast
2 changes: 1 addition & 1 deletion .github/workflows/cargo_test_examples.yml
Original file line number Diff line number Diff line change
Expand Up @@ -26,4 +26,4 @@ jobs:
# TEST THE LIBRARY
# ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
- name: Run examples.
run: cargo test --examples # --verbose
run: cargo test --examples --verbose --all-features --all-targets --no-fail-fast
2 changes: 1 addition & 1 deletion .github/workflows/cargo_test_library.yml
Original file line number Diff line number Diff line change
Expand Up @@ -26,4 +26,4 @@ jobs:
# TEST THE LIBRARY
# ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
- name: Run unit tests.
run: cargo test --lib # --verbose
run: cargo test --lib --verbose --all-features --all-targets --no-fail-fast
1 change: 1 addition & 0 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -85,6 +85,7 @@ argmin-math = "0.4.0" # https://docs.rs/argmin-math/latest/argmin_math/
derive_builder = "0.20.0" # https://docs.rs/derive_builder/latest/derive_builder/
errorfunctions = "0.2.0" # https://docs.rs/errorfunctions/latest/errorfunctions/
finitediff = "0.1.4" # https://docs.rs/finitediff/latest/finitediff/
icu = "1.5.0" # https://docs.rs/icu/latest/icu/
nalgebra = "0.33.0" # https://docs.rs/nalgebra/latest/nalgebra/
ndrustfft = "0.5.0" # https://docs.rs/ndrustfft/latest/ndrustfft/
ndarray-rand = "0.15.0" # https://docs.rs/ndarray-rand/latest/ndarray_rand/
Expand Down
4 changes: 2 additions & 2 deletions crates/RustQuant_time/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -20,8 +20,8 @@ RustQuant = { path = "../RustQuant" }
[dependencies]
RustQuant_iso = { workspace = true }
RustQuant_utils = { workspace = true }
icu = "1.5.0"
serde.workspace = true
icu = { workspace = true }
serde = { workspace = true }
time = { workspace = true }

## ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Expand Down
44 changes: 19 additions & 25 deletions crates/RustQuant_time/src/countries/middle_east/israel.rs
Original file line number Diff line number Diff line change
Expand Up @@ -7,16 +7,10 @@
// - LICENSE-MIT.md
// ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

// ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
// IMPORTS
// ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

use time::{Date, Weekday};

use icu;

use crate::calendar::Calendar;
use crate::utilities::unpack_date;
use icu;
use time::{Date, Weekday};
use RustQuant_iso::*;

// ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Expand Down Expand Up @@ -46,7 +40,7 @@ const JEWISH_HOLIDAYS: [(u8, u8); 16] = [
// STRUCTS, ENUMS, TRAITS
// ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

/// Israel a national holiday calendar.
/// Israel national holiday calendar.
pub struct IsraelCalendar;

// ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Expand Down Expand Up @@ -93,22 +87,22 @@ impl Calendar for IsraelCalendar {
hebrew_month -= 1;
}

let is_independence_or_memorial_day = match &(hebrew_month, hebrew_day, wd) {
(8, 3..=4, Weekday::Thursday) => true,
(8, 2..=3, Weekday::Wednesday) => true,
(8, 5, Weekday::Monday) => true,
(8, 6, Weekday::Tuesday) => true,
(8, 5, Weekday::Wednesday) => true,
(8, 4, Weekday::Tuesday) => true,
_ => false,
};

let is_tisha_beav = match &(hebrew_month, hebrew_day, wd) {
(11, 10, Weekday::Sunday) => true,
(11, 9, Weekday::Saturday) => false,
(11, 9, _) => true,
_ => false,
};
// Check if the date is Independence Day or Memorial Day.
let is_independence_or_memorial_day = matches!(
&(hebrew_month, hebrew_day, wd),
(8, 3..=4, Weekday::Thursday)
| (8, 2..=3, Weekday::Wednesday)
| (8, 5, Weekday::Monday)
| (8, 6, Weekday::Tuesday)
| (8, 5, Weekday::Wednesday)
| (8, 4, Weekday::Tuesday)
);

// Check if the date is Tisha Beav.
let is_tisha_beav = matches!(
&(hebrew_month, hebrew_day, wd),
(11, 10, Weekday::Sunday) | (11, 9, Weekday::Saturday) | (11, 9, _)
);

JEWISH_HOLIDAYS.contains(&(hebrew_month, hebrew_day))
|| is_independence_or_memorial_day
Expand Down

0 comments on commit 16a8bd7

Please sign in to comment.