diff --git a/worldsim/src/lodstore/data.rs b/worldsim/src/lodstore/data.rs index 4fa4d5f3f2..0113ec08e2 100644 --- a/worldsim/src/lodstore/data.rs +++ b/worldsim/src/lodstore/data.rs @@ -313,4 +313,28 @@ pub mod tests { } b.iter(|| x.trav(access).get().get().get().mat()); } + +/* + pub struct MyIterMut<'a, C> { + pub( super ) layer: &'a mut C, + } + #[derive(Default, Clone)] + pub struct Layer { + pub child: C, + } + pub trait EntryPoint { + type TRAV_MUT<'a>; + fn trav_mut<'a>(&'a mut self, pos: LodPos) -> Self::TRAV_MUT; + } + impl EntryPoint + for Layer + { + type TRAV_MUT<'a> = MyIterMut<'a, Layer>; + + fn trav_mut<'a>(&'a mut self, pos: u8) -> Self::TRAV_MUT { + MyIterMut { + layer: self, + } + } + }*/ } diff --git a/worldsim/src/lodstore/delta.rs b/worldsim/src/lodstore/delta.rs index 2b81e75389..97bdbacbf7 100644 --- a/worldsim/src/lodstore/delta.rs +++ b/worldsim/src/lodstore/delta.rs @@ -33,7 +33,7 @@ pub struct VecNestDelta { pub child: D, } -pub struct DeltaWriter<'a, C: EntryLayer + DetailStore, D: EntryLayer + DeltaStore> { +pub struct DeltaWriter<'a, C: DetailStore, D: DeltaStore> { pub delta: &'a mut D, pub data: &'a mut C, } @@ -53,7 +53,7 @@ pub struct DataWriterIter { //####################################################### -impl<'a, C: DetailStore + EntryLayer, D: DeltaStore + EntryLayer> DeltaWriter<'a, C, D> { +impl<'a, C: DetailStore, D: DeltaStore> DeltaWriter<'a, C, D> { pub fn new(delta: &'a mut D, data: &'a mut C) -> Self { DeltaWriter { delta, data } } @@ -187,7 +187,7 @@ mod stests { let mut d = ExampleDelta::default(); { let mut w = DeltaWriter::new(&mut d, &mut x); - //b.iter(|| w.trav_mut(LodPos::xyz(0, 0, 0))); + b.iter(|| {w.trav_mut(LodPos::xyz(0, 0, 0));}); } } @@ -197,7 +197,7 @@ mod stests { let mut d = ExampleDelta::default(); { let mut w = DeltaWriter::new(&mut d, &mut x); - //b.iter(|| w.trav_mut(LodPos::xyz(0, 0, 0)).get().get().get().mat()); + b.iter(|| {w.trav_mut(LodPos::xyz(0, 0, 0)).get().get().get().mat();}); } } @@ -222,7 +222,7 @@ mod stests { let mut d = ExampleDelta::default(); { let mut w = DeltaWriter::new(&mut d, &mut x); - //b.iter(|| {w.trav_mut_xxx(LodPos::xyz(0, 0, 0));}); + b.iter(|| {w.trav_mut(LodPos::xyz(0, 0, 0));}); } } /* diff --git a/worldsim/src/lodstore/entrylayer.rs b/worldsim/src/lodstore/entrylayer.rs index 7a458fb904..626a6ca708 100644 --- a/worldsim/src/lodstore/entrylayer.rs +++ b/worldsim/src/lodstore/entrylayer.rs @@ -4,6 +4,7 @@ use super::data::{HashNestLayer, DetailStore, HashIter, HashIterMut}; use super::delta::{VecNestDelta, DeltaStore, VecDeltaIter, VecDeltaIterMut, DataWriterIter, DeltaWriter}; use super::traversable::Traversable; +//TODO: actually implement EntryLayer pub trait EntryLayer { type TRAV<'a>: Traversable; type TRAV_MUT<'a>: Traversable; @@ -12,15 +13,9 @@ pub trait EntryLayer { } ///////////////// data types - -impl EntryLayer -for HashNestLayer +impl HashNestLayer { - type TRAV<'a> = HashIter<'a, HashNestLayer>; - type TRAV_MUT<'a> = HashIterMut<'a, HashNestLayer>; - - //ERROR make the HashIter C: remove the &'a from HashIter coding and implement it here - fn trav<'a>(&'a self, pos: LodPos) -> HashIter<'a, HashNestLayer> { + pub fn trav<'a>(&'a self, pos: LodPos) -> HashIter<'a, HashNestLayer> { HashIter { layer: self, wanted: pos, @@ -28,7 +23,7 @@ for HashNestLayer } } - fn trav_mut<'a>(&'a mut self, pos: LodPos) -> Self::TRAV_MUT { + pub fn trav_mut<'a>(&'a mut self, pos: LodPos) -> HashIterMut<'a, HashNestLayer> { HashIterMut { layer: self, wanted: pos, @@ -38,49 +33,25 @@ for HashNestLayer } ///////////////// delta types - -impl EntryLayer for VecNestDelta { - type TRAV<'a> = VecDeltaIter<'a, VecNestDelta>; - type TRAV_MUT<'a> = VecDeltaIterMut<'a, VecNestDelta>; - - fn trav<'a>(&'a self, _pos: LodPos) -> Self::TRAV { +impl VecNestDelta { + pub fn trav<'a>(&'a self, _pos: LodPos) -> VecDeltaIter<'a, VecNestDelta> { VecDeltaIter { layer: self } } - fn trav_mut<'a>(&'a mut self, _pos: LodPos) -> Self::TRAV_MUT { + pub fn trav_mut<'a>(&'a mut self, _pos: LodPos) -> VecDeltaIterMut<'a, VecNestDelta> { VecDeltaIterMut { layer: self } } } -impl EntryLayer -for DeltaWriter<'_, C, D> - where - <::TRAV as Traversable>::TRAV_CHILD: Traversable, - <::TRAV as Traversable>::TRAV_CHILD: Traversable, +impl DeltaWriter<'_, HashNestLayer, VecNestDelta> { - type TRAV<'a> = DataWriterIter; - type TRAV_MUT<'a> = DataWriterIter; - - fn trav<'a>(&'a self, pos: LodPos) -> Self::TRAV { + pub fn trav<'a>(&'a self, pos: LodPos) -> DataWriterIter>, HashIter<'a, HashNestLayer>> { DataWriterIter { delta_iter: self.delta.trav(pos), data_iter: self.data.trav(pos), } } - fn trav_mut<'a>(&'a mut self, pos: LodPos) -> Self::TRAV_MUT { - DataWriterIter { - delta_iter: self.delta.trav_mut(pos), - data_iter: self.data.trav_mut(pos), - } - } -} - -impl<'a, C: DetailStore + EntryLayer, D: DeltaStore + EntryLayer> DeltaWriter<'a, C, D> - where - <::TRAV as Traversable>::TRAV_CHILD: Traversable, - <::TRAV as Traversable>::TRAV_CHILD: Traversable, -{ - pub fn trav_mut_xxx(&mut self, pos: LodPos) -> DataWriterIter { + pub fn trav_mut<'a>(&'a mut self, pos: LodPos) -> DataWriterIter< VecDeltaIterMut<'a, VecNestDelta>, HashIterMut<'a, HashNestLayer>> { DataWriterIter { delta_iter: self.delta.trav_mut(pos), data_iter: self.data.trav_mut(pos),