diff --git a/newsfragments/5539.changed.md b/newsfragments/5539.changed.md new file mode 100644 index 00000000000..2ea40282f2d --- /dev/null +++ b/newsfragments/5539.changed.md @@ -0,0 +1 @@ +Expose types::iterator::PySendResult in public API diff --git a/src/types/iterator.rs b/src/types/iterator.rs index 7ee15531a2b..c41d2fb85eb 100644 --- a/src/types/iterator.rs +++ b/src/types/iterator.rs @@ -58,10 +58,13 @@ impl PyIterator { } } +/// Outcomes from sending a value into a python generator #[derive(Debug)] #[cfg(all(not(PyPy), Py_3_10))] pub enum PySendResult<'py> { + /// The generator yielded a new value Next(Bound<'py, PyAny>), + /// The generator completed, returning a (possibly None) final value Return(Bound<'py, PyAny>), } diff --git a/src/types/mod.rs b/src/types/mod.rs index 3dc8d9de6d9..8f99455dd33 100644 --- a/src/types/mod.rs +++ b/src/types/mod.rs @@ -27,6 +27,8 @@ pub use self::function::PyFunction; #[cfg(Py_3_9)] pub use self::genericalias::PyGenericAlias; pub use self::iterator::PyIterator; +#[cfg(all(not(PyPy), Py_3_10))] +pub use self::iterator::PySendResult; pub use self::list::{PyList, PyListMethods}; pub use self::mapping::{PyMapping, PyMappingMethods}; pub use self::mappingproxy::PyMappingProxy;