repo: stop wrapping view and index in Option in MutableRepo

I think the `Option<>` wrapping was from the time when `MutableView`
had a reference back to the repo (and `MutableIndex` was probably
wrapped out of habit).
This commit is contained in:
Martin von Zweigbergk 2021-03-08 00:04:26 -08:00
parent ef16d102e2
commit 9f7854f02c

View file

@ -451,8 +451,8 @@ impl RepoLoader {
pub struct MutableRepo<'r> { pub struct MutableRepo<'r> {
repo: &'r ReadonlyRepo, repo: &'r ReadonlyRepo,
index: Option<MutableIndex>, index: MutableIndex,
view: Option<MutableView>, view: MutableView,
evolution: Option<MutableEvolution<'static, 'static>>, evolution: Option<MutableEvolution<'static, 'static>>,
} }
@ -467,8 +467,8 @@ impl<'r> MutableRepo<'r> {
let mut_index = MutableIndex::incremental(index); let mut_index = MutableIndex::incremental(index);
let mut mut_repo = Arc::new(MutableRepo { let mut mut_repo = Arc::new(MutableRepo {
repo, repo,
index: Some(mut_index), index: mut_index,
view: Some(mut_view), view: mut_view,
evolution: None, evolution: None,
}); });
let repo_ref: &MutableRepo = mut_repo.as_ref(); let repo_ref: &MutableRepo = mut_repo.as_ref();
@ -490,11 +490,11 @@ impl<'r> MutableRepo<'r> {
} }
pub fn index(&self) -> &MutableIndex { pub fn index(&self) -> &MutableIndex {
self.index.as_ref().unwrap() &self.index
} }
fn index_mut(&mut self) -> &mut MutableIndex { fn index_mut(&mut self) -> &mut MutableIndex {
self.index.as_mut().unwrap() &mut self.index
} }
pub fn base_repo(&self) -> &'r ReadonlyRepo { pub fn base_repo(&self) -> &'r ReadonlyRepo {
@ -502,15 +502,15 @@ impl<'r> MutableRepo<'r> {
} }
pub fn view(&self) -> &MutableView { pub fn view(&self) -> &MutableView {
self.view.as_ref().unwrap() &self.view
} }
fn view_mut(&mut self) -> &mut MutableView { fn view_mut(&mut self) -> &mut MutableView {
self.view.as_mut().unwrap() &mut self.view
} }
pub fn consume(mut self) -> (MutableIndex, MutableView) { pub fn consume(self) -> (MutableIndex, MutableView) {
(self.index.take().unwrap(), self.view.take().unwrap()) (self.index, self.view)
} }
pub fn evolution<'m>(&'m self) -> &MutableEvolution<'r, 'm> { pub fn evolution<'m>(&'m self) -> &MutableEvolution<'r, 'm> {