MCPcopy Index your code
hub / github.com/RustPython/RustPython / get_or_try_init

Method get_or_try_init

crates/common/src/static_cell.rs:30–40  ·  view source on GitHub ↗
(&'static self, f: F)

Source from the content-addressed store, hash-verified

28 }
29
30 pub fn get_or_try_init<F, E>(&'static self, f: F) -> Result<&'static T, E>
31 where
32 F: FnOnce() -> Result<T, E>,
33 {
34 if let Some(val) = self.inner.get() {
35 return Ok(val);
36 }
37 let val = f()?;
38 let _ = self.inner.set(val);
39 Ok(self.inner.get().unwrap())
40 }
41 }
42
43 #[macro_export]

Callers

nothing calls this directly

Calls 6

leakFunction · 0.85
withMethod · 0.80
fFunction · 0.50
getMethod · 0.45
setMethod · 0.45
unwrapMethod · 0.45

Tested by

no test coverage detected