-
Notifications
You must be signed in to change notification settings - Fork 18
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
Support iterator protocol #42
Conversation
pydust/src/pytypes.zig
Outdated
if (@typeInfo(returnType) == .ErrorUnion) { | ||
const optional_result = result catch return null; | ||
const non_optional_result = optional_result orelse return null; | ||
return (trampoline.wrap(non_optional_result) catch return null).py; | ||
} | ||
const non_optional_result = result orelse return null; | ||
return (trampoline.wrap(non_optional_result) catch return null).py; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There is some additional unpacking here cause next can return null as valid - to stop iteration
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think having a separate tp_iternext_internal
function that can return errors might be useful?
pydust/src/pytypes.zig
Outdated
if (@typeInfo(returnType) == .ErrorUnion) { | ||
const optional_result = result catch return null; | ||
const non_optional_result = optional_result orelse return null; | ||
return (trampoline.wrap(non_optional_result) catch return null).py; | ||
} | ||
const non_optional_result = result orelse return null; | ||
return (trampoline.wrap(non_optional_result) catch return null).py; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think having a separate tp_iternext_internal
function that can return errors might be useful?
Addressed |
Co-authored-by: Nicholas Gates <[email protected]>
No description provided.