Conversation
c312410 to
6d3815e
Compare
|
Do we need the trait anymore than? We could use a |
Great call! I tried calling directly the
Yes! The new one is quite nice:
Yes, this way we avoid the not useful note: |
| T: 'static + Send + AssertNotZeroSized, | ||
| F: FnOnce(T, *mut c_void) + Send, | ||
| >( | ||
| pub fn new_with_destructor<T: 'static + Send, F: FnOnce(T, *mut c_void) + Send>( |
There was a problem hiding this comment.
Would it make sense to add a #[track_caller] here (and above) as well, so that the error does not point into pyo3 code?
|
I wonder, do we even need this assertion? I confess I forget why the original restriction was necessary, the best source I can find is #1980 (comment), where the restriction supposedly fixed a segfault (which might have just been due to an incorrect cast of the value coming out of the box). I can see why it's not helpful to ever want a ZST in a capsule (serves no purpose), so maybe we can keep this restriction and just clarify better for users why we don't accept it? |
Great point!
Maybe this restriction can be painful for some generic code? If they work, it seems more the realm of a warning than of an error. But I do not have a strong opinion on that, glad to tweak the MR to whatever the consensus is. |
|
I have opened #5889 that remove the zero-sized type limit and added a test that seems to pass |
It is now possible to do assertions in const functions, let's use that