-
Notifications
You must be signed in to change notification settings - Fork 792
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Fix a crate doc link for IterNextOutput #3129
Conversation
First time contributor has agreed to the new licensing scheme. |
I am not sure if the code example in the linked module-level documentation is really sufficient. I guess the best documentation on this we currently have is https://pyo3.rs/v0.18.3/class/protocols#iterable-objects but that is not part of the inline documentation. Would you be up to replacing the link by a dedicated example on how to use You can find the old example referenced here at https://github.com/PyO3/pyo3/blob/f4724dc1aa522d57f91401ef4842d8ed1e9bd546/src/class/iter.rs |
Hi @adamreichold , The old example seems moved here: Do you prefer replacing the link by a dedicated example or just pointing it to the pytests code above? |
030603f
to
8b94929
Compare
An inline example (even if it starts as a copy of the test) would definitely be helpful as it can be viewed without leaving the inline documentation (which for example is also available offline). |
I fear the CI is also broken independently of this change request. I will try to fix this separately... |
The example is copied together with some comments. It should look like this here: use pyo3::prelude::*;
use pyo3::iter::IterNextOutput;
#[pyclass]
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;
// Given an instance `counter`, First five `next(counter)` calls yield 1, 2, 3, 4, 5.
IterNextOutput::Yield(self.count)
} else {
// At the sixth time, we get a `StopIteration` with `'Ended'`.
// try:
// next(counter)
// except StopIteration as e:
// assert e.value == 'Ended'
IterNextOutput::Return("Ended")
}
}
} And good luck with the CI... |
The CI should be fixed now. I you remove the link, consent to the license change, fix the formatting and rebase onto the main branch, this should be good to go. |
4b83a32
to
f2b4761
Compare
* Remove the (eventually) stale ref link; * Typo: couter -> counter; * Fix the formatting with `cargo fmt`;
f2b4761
to
04f129f
Compare
Thanks for the help and patience! All issues mentioned above are now resolved.
|
Thank you for going the extra mile and helping us to improve the documentation! bors r+ |
Build succeeded! The publicly hosted instance of bors-ng is deprecated and will go away soon. If you want to self-host your own instance, instructions are here. If you want to switch to GitHub's built-in merge queue, visit their help page. |
This should fix the links 1 and 2.
They originally point to, which do not exist now: