MCPcopy Create free account
hub / github.com/dgrunwald/rust-cpython / with_extracted_or_default

Function with_extracted_or_default

src/argparse.rs:508–525  ·  view source on GitHub ↗

used in py_argparse_extract!() macro

(
    py: Python,
    obj: Option<&PyObject>,
    f: F,
    default: &'static P,
)

Source from the content-addressed store, hash-verified

506
507#[doc(hidden)] // used in py_argparse_extract!() macro
508pub fn with_extracted_or_default<P: ?Sized, R, F>(
509 py: Python,
510 obj: Option<&PyObject>,
511 f: F,
512 default: &'static P,
513) -> PyResult<R>
514where
515 F: FnOnce(&P) -> PyResult<R>,
516 P: RefFromPyObject,
517{
518 match obj {
519 Some(obj) => match P::with_extracted(py, obj, f) {
520 Ok(result) => result,
521 Err(e) => Err(e),
522 },
523 None => f(default),
524 }
525}
526
527#[doc(hidden)] // used in py_argparse_extract!() macro
528pub fn with_extracted_optional_or_default<P: ?Sized, R, F>(

Callers

nothing calls this directly

Calls 1

fFunction · 0.85

Tested by

no test coverage detected