Use Arbitrary Self Types instead of Py<Type>Methods traits #4885
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
For #4869.
I removed the
Deref
implementation forBound<'py, T>
because it conflicts with any implementation ofstd::ops::Receiver
we need to use Arbitrary Self Types. For example:I also added an implementation of
PyAnyMethods
forBound<'py, T>
to compensate for the removal ofDeref
. To get this working, I dropped the requirement thatPyAnyMethods
can only be implemented for sealed types. An alternative approach I think would be to just removeDeref
and require.as_any()
or.into_any()
calls in more places.After all of this,
clippy
passes on nightly on my machine (with the exception of one lint, which I think is unrelated to this PR). I can also run much of the test suite, but get an error in#[pyclass]
which I currently don't understand:I'm confident this is coming from
pyo3/pyo3-macros-backend/src/pyclass.rs
Line 1834 in 29c64d8
.as_type_ptr
method shouldn't be found, since it's implemented inpyo3/src/types/typeobject.rs
Lines 51 to 54 in 29c64d8