rs_measures/
define_measure_types.rs1pub enum UncertaintyFeatures {
2 None,
3 Symmetric,
4 TwoSided,
5}
6
7pub struct MeasureFeatures {
8 pub with_points: bool,
9 pub with_directions: bool,
10 pub with_2d: bool,
11 pub with_3d: bool,
12 pub with_transformations: bool,
13 pub with_uncertainty: UncertaintyFeatures,
14}
15
16#[macro_export]
17macro_rules! if_true {
18 { true, $fragment:item } => { $fragment };
19 { false, $fragment:item } => {};
20}
21
22#[macro_export]
23macro_rules! if_some_uncertainty {
24 { None, $fragment:item } => {};
25 { Symmetric, $fragment:item } => { $fragment };
26 { TwoSided, $fragment:item } => { $fragment };
27}
28
29#[macro_export]
30macro_rules! if_symmetric_uncertainty {
31 { None, $fragment:item } => {};
32 { Symmetric, $fragment:item } => { $fragment };
33 { TwoSided, $fragment:item } => {};
34}
35
36#[macro_export]
37macro_rules! if_two_sided_uncertainty {
38 { None, $fragment:item } => {};
39 { Symmetric, $fragment:item } => {};
40 { TwoSided, $fragment:item } => { $fragment };
41}
42
43#[macro_export]
44macro_rules! define_measure_types {
45 {
46 MeasureFeatures {
47 with_points: $with_points:tt,
48 with_directions: $with_directions:tt,
49 with_2d: $with_2d:tt,
50 with_3d: $with_3d:tt,
51 with_transformations: $with_transformations:tt,
52 with_uncertainty: $with_uncertainty:tt,
53 }
54 } => {
55 use core::ops::{Add, AddAssign, Div, DivAssign, Mul, MulAssign, Neg, Sub, SubAssign};
56 use rs_measures::{
57 angle::{Angle, Radian},
58 traits::{
59 AngleMeasurementUnit, ArithmeticOps, LossyFrom, MeasurementUnit, Sqrt, VectorProperty,
60 },
61 };
62 use std::fmt;
63 use std::marker::PhantomData;
64
65 rs_measures::inner_define_measure! {}
66 rs_measures::if_true! { $with_points,
67 rs_measures::inner_define_measure_point! {}
68 }
69 rs_measures::if_true! { $with_directions,
70 rs_measures::inner_define_unsigned_direction! {}
71 }
72 rs_measures::if_true! { $with_directions,
73 rs_measures::inner_define_signed_direction! {}
74 }
75 rs_measures::if_true! { $with_2d,
76 rs_measures::inner_define_measure_2d! { $with_points $with_directions }
77 }
78 rs_measures::if_true! { $with_2d,
79 rs_measures::if_true! { $with_points,
80 rs_measures::inner_define_measure_point_2d! {}
81 }
82 }
83 rs_measures::if_true! { $with_3d,
84 rs_measures::inner_define_measure_3d! {}
85 }
86 rs_measures::if_true! { $with_3d,
87 rs_measures::if_true! { $with_points,
88 rs_measures::inner_define_measure_point_3d! {}
89 }
90 }
91 rs_measures::if_true! { $with_2d,
92 rs_measures::if_true! { $with_transformations,
93 rs_measures::inner_define_linear_map_2d! {}
94 }
95 }
96 rs_measures::if_true! { $with_3d,
97 rs_measures::if_true! { $with_transformations,
98 rs_measures::inner_define_linear_map_3d! {}
99 }
100 }
101 rs_measures::if_true! { $with_2d,
102 rs_measures::if_true! { $with_transformations,
103 rs_measures::if_true! { $with_points,
104 rs_measures::inner_define_affine_map_2d! {}
105 }
106 }
107 }
108 rs_measures::if_true! { $with_3d,
109 rs_measures::if_true! { $with_transformations,
110 rs_measures::if_true! { $with_points,
111 rs_measures::inner_define_affine_map_3d! {}
112 }
113 }
114 }
115 };
116}