rust_zmanim/complex_zmanim_calendar/
czc_macros.rs1#[macro_export]
2macro_rules! zmanim_for_offset {
3 ($offset_fn:expr, [$($fn_name:ident => $zman_type:ident, $doc:expr),* $(,)?]) => {
5 $(
6 zmanim_for_offset!(@method_custom $fn_name, $offset_fn, $zman_type, $doc);
7 )*
8 };
9
10 (@method_custom $fn_name:ident, $offset_fn:expr, shaah_zmanis_mga, $doc:expr) => {
12 #[must_use]
13 #[doc = $doc]
14 pub fn $fn_name(&self) -> Option<TimeDelta> {
15 let offset = ($offset_fn)(self)?;
16 self.shaah_zmanis_mga(&offset)
17 }
18 };
19
20 (@method_custom $fn_name:ident, $offset_fn:expr, $zman_type:ident, $doc:expr) => {
22 #[must_use]
23 #[doc = $doc]
24 pub fn $fn_name(&self) -> Option<DateTime<Tz>> {
25 let offset = ($offset_fn)(self)?;
26 self.$zman_type(&offset)
27 }
28 };
29}