luaur_common/methods/
variant_variant_variant_alt_b.rs1impl<T0: 'static> crate::records::variant::Variant1<T0> {
2 pub fn variant_t_enable_if_t_get_type_id_t<T: 'static>(value: T) -> Self {
3 let tid = Self::get_type_id::<T>();
4 unsafe {
5 let ptr = &value as *const T;
6 core::mem::forget(value);
7 match tid {
8 0 => Self::V0(core::ptr::read(ptr as *const T0)),
9 _ => panic!("Variant1: type not found in variant"),
10 }
11 }
12 }
13}
14
15impl<T0: 'static, T1: 'static> crate::records::variant::Variant2<T0, T1> {
16 pub fn variant_t_enable_if_t_get_type_id_t<T: 'static>(value: T) -> Self {
17 let tid = Self::get_type_id::<T>();
18 unsafe {
19 let ptr = &value as *const T;
20 core::mem::forget(value);
21 match tid {
22 0 => Self::V0(core::ptr::read(ptr as *const T0)),
23 1 => Self::V1(core::ptr::read(ptr as *const T1)),
24 _ => panic!("Variant2: type not found in variant"),
25 }
26 }
27 }
28}
29
30impl<T0: 'static, T1: 'static, T2: 'static> crate::records::variant::Variant3<T0, T1, T2> {
31 pub fn variant_t_enable_if_t_get_type_id_t<T: 'static>(value: T) -> Self {
32 let tid = Self::get_type_id::<T>();
33 unsafe {
34 let ptr = &value as *const T;
35 core::mem::forget(value);
36 match tid {
37 0 => Self::V0(core::ptr::read(ptr as *const T0)),
38 1 => Self::V1(core::ptr::read(ptr as *const T1)),
39 2 => Self::V2(core::ptr::read(ptr as *const T2)),
40 _ => panic!("Variant3: type not found in variant"),
41 }
42 }
43 }
44}
45
46impl<T0: 'static, T1: 'static, T2: 'static, T3: 'static>
47 crate::records::variant::Variant4<T0, T1, T2, T3>
48{
49 pub fn variant_t_enable_if_t_get_type_id_t<T: 'static>(value: T) -> Self {
50 let tid = Self::get_type_id::<T>();
51 unsafe {
52 let ptr = &value as *const T;
53 core::mem::forget(value);
54 match tid {
55 0 => Self::V0(core::ptr::read(ptr as *const T0)),
56 1 => Self::V1(core::ptr::read(ptr as *const T1)),
57 2 => Self::V2(core::ptr::read(ptr as *const T2)),
58 3 => Self::V3(core::ptr::read(ptr as *const T3)),
59 _ => panic!("Variant4: type not found in variant"),
60 }
61 }
62 }
63}
64
65impl<T0: 'static, T1: 'static, T2: 'static, T3: 'static, T4: 'static>
66 crate::records::variant::Variant5<T0, T1, T2, T3, T4>
67{
68 pub fn variant_t_enable_if_t_get_type_id_t<T: 'static>(value: T) -> Self {
69 let tid = Self::get_type_id::<T>();
70 unsafe {
71 let ptr = &value as *const T;
72 core::mem::forget(value);
73 match tid {
74 0 => Self::V0(core::ptr::read(ptr as *const T0)),
75 1 => Self::V1(core::ptr::read(ptr as *const T1)),
76 2 => Self::V2(core::ptr::read(ptr as *const T2)),
77 3 => Self::V3(core::ptr::read(ptr as *const T3)),
78 4 => Self::V4(core::ptr::read(ptr as *const T4)),
79 _ => panic!("Variant5: type not found in variant"),
80 }
81 }
82 }
83}
84
85impl<T0: 'static, T1: 'static, T2: 'static, T3: 'static, T4: 'static, T5: 'static>
86 crate::records::variant::Variant6<T0, T1, T2, T3, T4, T5>
87{
88 pub fn variant_t_enable_if_t_get_type_id_t<T: 'static>(value: T) -> Self {
89 let tid = Self::get_type_id::<T>();
90 unsafe {
91 let ptr = &value as *const T;
92 core::mem::forget(value);
93 match tid {
94 0 => Self::V0(core::ptr::read(ptr as *const T0)),
95 1 => Self::V1(core::ptr::read(ptr as *const T1)),
96 2 => Self::V2(core::ptr::read(ptr as *const T2)),
97 3 => Self::V3(core::ptr::read(ptr as *const T3)),
98 4 => Self::V4(core::ptr::read(ptr as *const T4)),
99 5 => Self::V5(core::ptr::read(ptr as *const T5)),
100 _ => panic!("Variant6: type not found in variant"),
101 }
102 }
103 }
104}
105
106impl<T0: 'static, T1: 'static, T2: 'static, T3: 'static, T4: 'static, T5: 'static, T6: 'static>
107 crate::records::variant::Variant7<T0, T1, T2, T3, T4, T5, T6>
108{
109 pub fn variant_t_enable_if_t_get_type_id_t<T: 'static>(value: T) -> Self {
110 let tid = Self::get_type_id::<T>();
111 unsafe {
112 let ptr = &value as *const T;
113 core::mem::forget(value);
114 match tid {
115 0 => Self::V0(core::ptr::read(ptr as *const T0)),
116 1 => Self::V1(core::ptr::read(ptr as *const T1)),
117 2 => Self::V2(core::ptr::read(ptr as *const T2)),
118 3 => Self::V3(core::ptr::read(ptr as *const T3)),
119 4 => Self::V4(core::ptr::read(ptr as *const T4)),
120 5 => Self::V5(core::ptr::read(ptr as *const T5)),
121 6 => Self::V6(core::ptr::read(ptr as *const T6)),
122 _ => panic!("Variant7: type not found in variant"),
123 }
124 }
125 }
126}