diff --git a/src/data/entities.rs b/src/data/entities.rs index 5959cfc..17703c6 100644 --- a/src/data/entities.rs +++ b/src/data/entities.rs @@ -180,10 +180,11 @@ impl CardStatistics { #[derive(Clone, Copy)] pub struct EntityHandle { - pub(crate) _phantom: PhantomData, pub(crate) id: Id, pub(crate) real: bool, pub(crate) index: u32, + pub(crate) _phantom: PhantomData, + } pub trait EntityData{ diff --git a/src/data/repositories.rs b/src/data/repositories.rs index d8b8948..d517e3a 100644 --- a/src/data/repositories.rs +++ b/src/data/repositories.rs @@ -241,8 +241,8 @@ for DataRepositoryInner h.real = true; } - for handle in cached.iter_mut() { - let h = &mut **handle; + for handle in cached.into_iter() { + let h = handle; let idx = fast_position_of(self.cache.as_slice(), h).unwrap(); self.data_layer .write_entity(&self.cache[idx], &self.connection.lock())?; diff --git a/src/tests.rs b/src/tests.rs index db4efda..a49b7f9 100644 --- a/src/tests.rs +++ b/src/tests.rs @@ -65,7 +65,7 @@ mod mod_tests { }; assert_eq!( fast_position_of(&[1, 2, 3, 8, 9, 12].map(ProtoEntity::new), &mut entity), - Some(1) + Some(4) ); } @@ -75,7 +75,7 @@ mod mod_tests { _phantom: Default::default(), id: 106.into(), real: true, - index: 5, + index: 25, }; assert_eq!( fast_position_of( @@ -86,7 +86,7 @@ mod mod_tests { .map(ProtoEntity::new), &mut entity ), - Some(1) + Some(18) ); } }