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

Method enter_and_expect

crates/vm/src/vm/interpreter.rs:367–375  ·  view source on GitHub ↗

Run [`Interpreter::enter`] and call [`VirtualMachine::expect_pyresult`] for the result. This function is useful when you want to expect a result from the function, but also print useful panic information when exception raised. See also [`Interpreter::enter`] and [`VirtualMachine::expect_pyresult`] for more information.

(&self, f: F, msg: &str)

Source from the content-addressed store, hash-verified

365 ///
366 /// See also [`Interpreter::enter`] and [`VirtualMachine::expect_pyresult`] for more information.
367 pub fn enter_and_expect<F, R>(&self, f: F, msg: &str) -> R
368 where
369 F: FnOnce(&VirtualMachine) -> PyResult<R>,
370 {
371 self.enter(|vm| {
372 let result = f(vm);
373 vm.expect_pyresult(result, msg)
374 })
375 }
376
377 /// Run a function with the main virtual machine and return exit code.
378 ///

Callers

nothing calls this directly

Calls 3

expect_pyresultMethod · 0.80
fFunction · 0.50
enterMethod · 0.45

Tested by

no test coverage detected