difftreelog
fix force_value in LazyValue
in: master
1 file changed
pallets/common/src/lib.rsdiffbeforeafterboth888888889 /// Get the value. If it is called the first time, the value will be initialized.889 /// Get the value. If it is called the first time, the value will be initialized.890 pub fn value(&mut self) -> &T {890 pub fn value(&mut self) -> &T {891 self.compute_value_if_not_already();891 self.force_value();892 self.value.as_ref().unwrap()892 self.value.as_ref().unwrap()893 }893 }894894895 /// Get the value. If it is called the first time, the value will be initialized.895 /// Get the value. If it is called the first time, the value will be initialized.896 pub fn value_mut(&mut self) -> &mut T {896 pub fn value_mut(&mut self) -> &mut T {897 self.compute_value_if_not_already();897 self.force_value();898 self.value.as_mut().unwrap()898 self.value.as_mut().unwrap()899 }899 }900900901 fn into_inner(mut self) -> T {901 fn into_inner(mut self) -> T {902 self.compute_value_if_not_already();902 self.force_value();903 self.value.unwrap()903 self.value.unwrap()904 }904 }905905908 self.value.is_some()908 self.value.is_some()909 }909 }910910911 fn compute_value_if_not_already(&mut self) {911 fn force_value(&mut self) {912 if self.value.is_none() {912 if self.value.is_none() {913 self.value = Some(self.f.take().unwrap()())913 self.value = Some(self.f.take().unwrap()())914 }914 }