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

Method get_or_try_init

crates/common/src/atomic.rs:101–110  ·  view source on GitHub ↗
(&self, f: F)

Source from the content-addressed store, hash-verified

99 }
100
101 pub fn get_or_try_init<F, E>(&self, f: F) -> Result<NonNull<T>, E>
102 where
103 F: FnOnce() -> Result<Box<T>, E>,
104 {
105 if let Some(val) = self.get() {
106 return Ok(val);
107 }
108
109 Ok(self.initialize(f()?))
110 }
111
112 #[cold]
113 fn initialize(&self, val: Box<T>) -> NonNull<T> {

Callers 2

get_or_initMethod · 0.45
delegate_pycodecsFunction · 0.45

Calls 3

fFunction · 0.50
getMethod · 0.45
initializeMethod · 0.45

Tested by

no test coverage detected