Skip to main content

luaur_common/methods/
variant_get_if_variant_alt_b.rs

1impl<T0: 'static, T1: 'static, T2: 'static, T3: 'static, T4: 'static, T5: 'static, T6: 'static>
2    crate::records::variant::Variant7<T0, T1, T2, T3, T4, T5, T6>
3{
4    pub fn get_if_mut<T: 'static>(&mut self) -> ::core::option::Option<&mut T> {
5        let tid = Self::get_type_id::<T>();
6        match tid {
7            0 => self
8                .get_if_0_mut()
9                .map(|x| unsafe { &mut *(x as *mut T0 as *mut T) }),
10            1 => self
11                .get_if_1_mut()
12                .map(|x| unsafe { &mut *(x as *mut T1 as *mut T) }),
13            2 => self
14                .get_if_2_mut()
15                .map(|x| unsafe { &mut *(x as *mut T2 as *mut T) }),
16            3 => self
17                .get_if_3_mut()
18                .map(|x| unsafe { &mut *(x as *mut T3 as *mut T) }),
19            4 => self
20                .get_if_4_mut()
21                .map(|x| unsafe { &mut *(x as *mut T4 as *mut T) }),
22            5 => self
23                .get_if_5_mut()
24                .map(|x| unsafe { &mut *(x as *mut T5 as *mut T) }),
25            6 => self
26                .get_if_6_mut()
27                .map(|x| unsafe { &mut *(x as *mut T6 as *mut T) }),
28            _ => ::core::option::Option::None,
29        }
30    }
31}