Skip to content

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