pub struct AnyOtherType; pub struct Aa(pub T,pub V,pub M); impl Aa where T: std::ops::AddAssign + Clone, V: IntoIterator + Clone, M: std::ops::AddAssign + Clone, { pub fn add(&mut self, v: T){ self.0 += v; } pub fn push(&mut self, v: V) where V::Item: Into + std::ops::AddAssign, { self.1 = v.clone(); for i in v{ self.2 += i.into() } } pub fn set < W: Into, Z: Into>(&mut self,input_first: W, input_last: Z) { self.0 = input_first.into(); self.2 = input_last.into(); } pub fn get_values(&self) -> (T,V,M){ (self.0.clone(),self.1.clone(),self.2.clone()) } } pub struct Bb(pub T,pub V,pub M); impl Bb where T: std::ops::AddAssign + Clone, V: IntoIterator + Clone, M: std::ops::AddAssign + Clone, { pub fn add(&mut self, v: T){ self.0 += v; } pub fn push(&mut self, v: V) where V::Item: Into + std::ops::AddAssign, { self.1 = v.clone(); for i in v{ self.2 += i.into() } } pub fn set < W: Into, Z: Into>(&mut self,input_first: W, input_last: Z) { self.0 = input_first.into(); self.2 = input_last.into(); } pub fn get_values(&self) -> (T,V,M){ (self.0.clone(),self.1.clone(),self.2.clone()) } } pub struct Cc(pub T,pub V,pub M); impl Cc where T: std::ops::AddAssign + Clone, V: IntoIterator + Clone, M: std::ops::AddAssign + Clone, { pub fn add(&mut self, v: T){ self.0 += v; } pub fn push(&mut self, v: V) where V::Item: Into + std::ops::AddAssign, { self.1 = v.clone(); for i in v{ self.2 += i.into() } } pub fn set < W: Into, Z: Into>(&mut self,input_first: W, input_last: Z) { self.0 = input_first.into(); self.2 = input_last.into(); } pub fn get_values(&self) -> (T,V,M){ (self.0.clone(),self.1.clone(),self.2.clone()) } } pub struct AaBbCc { pub a: Aa, pub b: Bb, pub c: Cc, _any: AnyOtherType, } #[interthread::group(show,file="examples/intro_group_generic.rs",debut)] impl AaBbCc where Tc: std::ops::AddAssign + Clone, Vc: IntoIterator + Clone, Mc: std::ops::AddAssign + Clone, Tb: std::ops::AddAssign + Clone, Vb: IntoIterator + Clone, Mb: std::ops::AddAssign + Clone, Ta: std::ops::AddAssign + Clone, Va: IntoIterator + Clone, Ma: std::ops::AddAssign + Clone, { pub fn new( a: Aa, b: Bb, c: Cc ) -> Self { let a = a; let b = b; let c = c; let _any = AnyOtherType; Self{ a,b,c,_any } } pub fn add_to_a(&mut self, v:Ta){ self.a.0 += v; } pub fn get_values_of_a(&mut self)-> (Ta,Va,Ma) { self.a.get_values() } pub fn get_values_of_b(&mut self)-> (Tb,Vb,Mb) { self.b.get_values() } pub fn get_values_of_c(&mut self)-> (Tc,Vc,Mc) { self.c.get_values() } } // #[interthread::example(main(path = "examples/intro_group_generic.rs"))] pub fn main(){ let aa = Aa(8u8, vec![1u16,1,1],1u32); let bb = Bb(8u16,vec![1u16,1,1],1u32); let cc = Cc(8u32,vec![1u16,1,1],1u32); let mut group = AaBbCcGroupLive::new(aa,bb,cc); group.a.set(1u8,1u8); group.b.set(1u8,1u8); group.c.set(1u8,1u8); group.add_to_a(5); println!("Value of a - {:?}",group.get_values_of_a()); println!("Value of b - {:?}",group.get_values_of_b()); println!("Value of c - {:?}",group.get_values_of_c()); }