Skip to content

Commit

Permalink
Refine the example for IterNextOutput
Browse files Browse the repository at this point in the history
* Remove the (eventually) stale ref link;
* Typo: couter -> counter;
* Fix the formatting with `cargo fmt`;
  • Loading branch information
cfour2 committed May 2, 2023
1 parent 1ca1dc3 commit 04f129f
Showing 1 changed file with 3 additions and 5 deletions.
8 changes: 3 additions & 5 deletions src/pyclass.rs
Original file line number Diff line number Diff line change
Expand Up @@ -100,14 +100,14 @@ impl CompareOp {
/// struct PyClassIter {
/// count: usize,
/// }
///
///
/// #[pymethods]
/// impl PyClassIter {
/// #[new]
/// pub fn new() -> Self {
/// PyClassIter { count: 0 }
/// }
///
///
/// fn __next__(&mut self) -> IterNextOutput<usize, &'static str> {
/// if self.count < 5 {
/// self.count += 1;
Expand All @@ -116,16 +116,14 @@ impl CompareOp {
/// } else {
/// // At the sixth time, we get a `StopIteration` with `'Ended'`.
/// // try:
/// // next(couter)
/// // next(counter)
/// // except StopIteration as e:
/// // assert e.value == 'Ended'
/// IterNextOutput::Return("Ended")
/// }
/// }
/// }
/// ```
///
/// The example above is copied from [this test](https://github.com/PyO3/pyo3/blob/main/pytests/src/pyclasses.rs#L15-L36).
pub enum IterNextOutput<T, U> {
/// The value yielded by the iterator.
Yield(T),
Expand Down

0 comments on commit 04f129f

Please sign in to comment.