clay_core/shape/
select.rs1#[macro_export]
5macro_rules! shape_select {
6 ( $Select:ident { $( $Enum:ident ( $Param:ident = $Shape:ty ) ),+ $(,)? } ) => {
7 $crate::instance_select!(
8 $Select: $crate::shape::Shape: $crate::shape::ShapeClass {
9 $( $Enum($Param = $Shape) ),+
10 }
11 );
12 impl $crate::shape::Shape for $Select {}
13
14 impl<
15 B_: $crate::shape::Bound,
16 $(
17 $Param:
18 $crate::shape::Shape +
19 $crate::shape::Bounded<B_>
20 ),+
21 > $crate::shape::Bounded<B_> for $Select<
22 $( $Param ),+
23 > {
24 fn bound(&self) -> Option<B_> {
25 match self {
26 $( $Select::$Enum(x) => x.bound(), )+
27 }
28 }
29 }
30 };
31}
32
33#[cfg(test)]
34mod check {
35 use crate::{
36 shape::test::TestShape,
37 shape_select,
38 };
39
40 shape_select!(
41 TestShapeSelect {
42 Shape1(T1 = TestShape<i32>),
43 Shape2(T2 = TestShape<f32>),
44 }
45 );
46}