transaction: make evolution_mut() return a mutable reference

This includes fixing a lifetime bound on `MutableEvolution` that was
reversed.
This commit is contained in:
Martin von Zweigbergk 2020-12-23 01:06:05 -08:00
parent 110c083e78
commit 0219dbb359
2 changed files with 6 additions and 4 deletions

View File

@ -309,7 +309,7 @@ impl<'r> ReadonlyEvolution<'r> {
}
}
pub struct MutableEvolution<'r, 'm: 'r> {
pub struct MutableEvolution<'r: 'm, 'm> {
repo: &'m MutableRepo<'r>,
state: State,
}

View File

@ -219,8 +219,10 @@ impl<'r> Repo for MutableRepo<'r> {
}
}
impl MutableRepo<'_> {
pub fn evolution_mut(&mut self) -> &MutableEvolution {
self.evolution.as_mut().unwrap()
impl<'r> MutableRepo<'r> {
pub fn evolution_mut<'m>(&'m mut self) -> &'m mut MutableEvolution<'r, 'm> {
let evolution: &mut MutableEvolution<'static, 'static> = self.evolution.as_mut().unwrap();
let evolution: &mut MutableEvolution<'r, 'm> = unsafe { std::mem::transmute(evolution) };
evolution
}
}