Skip to content

Make type() bases arg only take tuples #2342

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 4 commits into from
Dec 12, 2020

Conversation

carbotaniuman
Copy link
Contributor

No description provided.

@coolreader18
Copy link
Member

You can call .borrow_value() on the tuple to get a &[PyObjectRef], and then use that instead of the PyIterable

@coolreader18
Copy link
Member

Oh I see, cause it has to be Vec<PyTypeRef>. Maybe just .borrow_value().iter().map(typeref tryfromobject).collect::<PyResult<Vec<PyTypeRef>>()?

@coolreader18
Copy link
Member

I recently added a builtins::tuple::PyTupleTyped type, you could try making the type of bases: PyTupleTyped<PyTypeRef>

@carbotaniuman
Copy link
Contributor Author

Updated. Is there a reason you added the Transmute... trait instead of just TryFromObject?

@coolreader18
Copy link
Member

TryFromObject is implemented for a ton of different types and doesn't have any invariants regarding representation, e.g. if it just required TryFromObject you could have PyTupleTyped<u8>, and that obviously wouldn't be safe to cast PyObjectRef to u8. TransmuteFromObject is an unsafe trait, so if anyone wants to implement it wrong they have to use unsafe to do so 🙃

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.

Thanks for contributing!

@coolreader18 coolreader18 merged commit 7681892 into RustPython:master Dec 12, 2020
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