| 646 #[cfg(feature = "pyo3")] |
646 #[cfg(feature = "pyo3")] |
| 647 mod python { |
647 mod python { |
| 648 use super::Pair; |
648 use super::Pair; |
| 649 use pyo3::conversion::FromPyObject; |
649 use pyo3::conversion::FromPyObject; |
| 650 use pyo3::types::{PyAny, PyTuple}; |
650 use pyo3::types::{PyAny, PyTuple}; |
| 651 use pyo3::{Bound, IntoPyObject, PyErr, PyResult, Python}; |
651 use pyo3::{Borrowed, Bound, IntoPyObject, PyErr, Python}; |
| 652 |
652 |
| 653 impl<'py, A, B> IntoPyObject<'py> for Pair<A, B> |
653 impl<'py, A, B> IntoPyObject<'py> for Pair<A, B> |
| 654 where |
654 where |
| 655 A: IntoPyObject<'py>, |
655 A: IntoPyObject<'py>, |
| 656 B: IntoPyObject<'py>, |
656 B: IntoPyObject<'py>, |
| 692 (&self.0, &self.1).into_pyobject(py) |
692 (&self.0, &self.1).into_pyobject(py) |
| 693 } |
693 } |
| 694 } |
694 } |
| 695 */ |
695 */ |
| 696 |
696 |
| 697 impl<'py, A, B> FromPyObject<'py> for Pair<A, B> |
697 impl<'a, 'py, A, B> FromPyObject<'a, 'py> for Pair<A, B> |
| 698 where |
698 where |
| 699 A: Clone + FromPyObject<'py>, |
699 A: Clone + FromPyObject<'a, 'py>, |
| 700 B: Clone + FromPyObject<'py>, |
700 B: Clone + FromPyObject<'a, 'py>, |
| 701 { |
701 { |
| 702 fn extract_bound(ob: &Bound<'py, PyAny>) -> PyResult<Self> { |
702 type Error = PyErr; |
| 703 FromPyObject::extract_bound(ob).map(|(a, b)| Pair(a, b)) |
703 |
| 704 } |
704 fn extract(ob: Borrowed<'a, 'py, PyAny>) -> Result<Self, PyErr> { |
| 705 } |
705 FromPyObject::extract(ob).map(|(a, b)| Pair(a, b)) |
| 706 } |
706 } |
| |
707 } |
| |
708 } |