Skip to content

Commit

Permalink
Added more docs
Browse files Browse the repository at this point in the history
  • Loading branch information
bschoenmaeckers committed Dec 9, 2024
1 parent e1449f8 commit cac596e
Showing 1 changed file with 10 additions and 3 deletions.
13 changes: 10 additions & 3 deletions src/types/iterator.rs
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,10 @@ pub enum PySendResult<'py> {
}

impl<'py> Bound<'py, PyIterator> {
/// Sends a value into the iterator.
/// Sends a value into a python generator. This is the equivalent of calling `generator.send(value)` in Python.
/// This resumes the generator and continues its execution until the next `yield` or `return` statement.
/// If the generator exits without returning a value, this function returns a `StopException`.
/// The first call to `send` must be made with `None` as the argument to start the generator, failing to do so will raise a `TypeError`.
#[inline]
#[cfg(all(not(PyPy), Py_3_10))]
pub fn send(&self, value: &Bound<'py, PyAny>) -> PyResult<PySendResult<'py>> {
Expand Down Expand Up @@ -130,9 +133,13 @@ impl PyTypeCheck for PyIterator {

#[cfg(test)]
mod tests {
use super::{PyIterator, PySendResult};
use super::PyIterator;
#[cfg(all(not(PyPy), Py_3_10))]
use super::PySendResult;
use crate::exceptions::PyTypeError;
use crate::types::{PyAnyMethods, PyDict, PyList, PyListMethods, PyNone};
#[cfg(all(not(PyPy), Py_3_10))]
use crate::types::PyNone;
use crate::types::{PyAnyMethods, PyDict, PyList, PyListMethods};
use crate::{ffi, IntoPyObject, Python};

#[test]
Expand Down

0 comments on commit cac596e

Please sign in to comment.