Use .take() rather than replace(..., None)

This commit is contained in:
Gwilym Inzani 2023-04-12 13:49:22 +01:00
parent fc5ce97db4
commit 5f59a01c21

View file

@ -11,7 +11,6 @@ impl<T> Singleton<T> {
Singleton { single: None } Singleton { single: None }
} }
pub fn take(&mut self) -> T { pub fn take(&mut self) -> T {
let g = core::mem::replace(&mut self.single, None); self.single.take().unwrap()
g.unwrap()
} }
} }