Skip to content

derive(TryIntoPyStructSequence) #3613

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

Merged
merged 6 commits into from
Apr 19, 2022

Conversation

youknowone
Copy link
Member

No description provided.

@youknowone youknowone requested a review from coolreader18 April 14, 2022 14:55
@youknowone youknowone force-pushed the pystructseq-fromobj branch from 01ef615 to 7cd2b8b Compare April 14, 2022 14:58
@youknowone youknowone mentioned this pull request Apr 14, 2022
@youknowone youknowone force-pushed the pystructseq-fromobj branch 3 times, most recently from 5d810e4 to 899e794 Compare April 18, 2022 20:20
@youknowone youknowone mentioned this pull request Apr 19, 2022
Copy link
Member

@coolreader18 coolreader18 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM!

impl ::rustpython_vm::TryFromObject for #ty {
fn try_from_object(vm: &::rustpython_vm::VirtualMachine, seq: ::rustpython_vm::PyObjectRef) -> ::rustpython_vm::PyResult<Self> {
let seq = Self::try_elements_from(seq, vm)?;
let mut iter = seq.into_iter();
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yeah, this could probably be let seq: [PyObjectRef; <#ty as ::rustpython_vm::types::PyStructSeq>::FIELD_NAMES.len()] = seq.try_into().unwrap();

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

no idea how to handle index in quote!()

@youknowone youknowone force-pushed the pystructseq-fromobj branch from 899e794 to 41000c4 Compare April 19, 2022 06:32
@youknowone youknowone merged commit 16cedb1 into RustPython:main Apr 19, 2022
@youknowone youknowone deleted the pystructseq-fromobj branch April 19, 2022 07:20
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants