used in py_argparse_extract!() macro
(
py: Python,
obj: Option<&PyObject>,
f: F,
default: &'static P,
)
| 506 | |
| 507 | #[doc(hidden)] // used in py_argparse_extract!() macro |
| 508 | pub 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> |
| 514 | where |
| 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 |
| 528 | pub fn with_extracted_optional_or_default<P: ?Sized, R, F>( |