use std::pin::pin; use temp_inst::{TempInst, TempInstPin, TempRef, TempRefMut}; use temp_inst_derive::{TempRepr, TempReprMut, TempReprMutChk}; #[derive(TempRepr, TempReprMut, TempReprMutChk)] struct EmptyStruct; #[test] fn empty_struct() { let _ = TempInst::::new(()); } #[derive(TempRepr, TempReprMut, TempReprMutChk)] struct EmptyStruct2(); #[test] fn empty_struct_2() { let _ = TempInst::::new(()); } #[derive(TempRepr, TempReprMut, TempReprMutChk)] struct Unit(()); #[test] fn unit() { let _ = TempInst::::new(()); } #[derive(TempRepr, TempReprMut, TempReprMutChk)] struct Unit2 { field0: (), } #[test] fn unit_2() { let _ = TempInst::::new(()); } #[derive(TempRepr, TempReprMut, TempReprMutChk)] struct Single(TempRef); #[test] fn single() { let temp = TempInst::::new(&0); assert_eq!(*temp.0, 0); } #[derive(TempRepr, TempReprMut, TempReprMutChk)] struct Single2 { field0: TempRef, } #[test] fn single_2() { let temp = TempInst::::new(&0); assert_eq!(*temp.field0, 0); } #[derive(TempRepr, TempReprMut, TempReprMutChk)] struct SingleMut(TempRefMut); #[test] fn single_mut() { let mut field0 = 0; let temp = pin!(TempInstPin::::new(&mut field0)); let temp = temp.deref_pin(); assert_eq!(*temp.0, 0); } #[derive(TempRepr, TempReprMut, TempReprMutChk)] struct Multi(TempRef, TempRef); #[test] fn multi() { let temp = TempInst::::new((&0, &1)); assert_eq!(*temp.0, 0); assert_eq!(*temp.1, 1); } #[derive(TempRepr, TempReprMut, TempReprMutChk)] struct Multi2 { field0: TempRef, field1: TempRef, } #[test] fn multi_2() { let temp = TempInst::::new((&0, &1)); assert_eq!(*temp.field0, 0); assert_eq!(*temp.field1, 1); } #[derive(TempRepr, TempReprMut, TempReprMutChk)] struct MultiMut(TempRefMut, TempRefMut); #[test] fn multi_mut() { let mut field0 = 0; let mut field1 = 1; let temp = pin!(TempInstPin::::new((&mut field0, &mut field1))); let temp = temp.deref_pin(); assert_eq!(*temp.0, 0); assert_eq!(*temp.1, 1); }