pub fn new_with_destructor<
        'py,
        T: 'static + Send + AssertNotZeroSized,
        F: FnOnce(T, *mut c_void),
    >(
        py: Python<'py>,
        value: T,
        name: &CStr,
        destructor: F,
    ) -> PyResult<&'py Self> {
        AssertNotZeroSized::assert_not_zero_sized(&value);
        let val = Box::new(CapsuleContents { value, destructor });

        let cap_ptr = unsafe {
            ffi::PyCapsule_New(
                Box::into_raw(val) as *mut c_void,
                name.as_ptr(),
                Some(capsule_destructor::<T, F>),
            )
        };
        unsafe { py.from_owned_ptr_or_err(cap_ptr) }
    }
/// Constructs a new capsule whose contents are `value`, associated with `name`.
///
/// Also provides a destructor: when the `PyCapsule` is destroyed, it will be passed the original object,
/// as well as a `*mut c_void` which will point to the capsule's context, if any.
Constructs a new capsule whose contents are `value`, associated with `name`.
Also provides a destructor: when the `PyCapsule` is destroyed, it will be passed the original object,
as well as a `*mut c_void` which will point to the capsule's context, if any.
Constructs a new capsule whose contents are ` value ` associated with ` name ` . Also provides a destructor : when the ` PyCapsule ` is destroyed it will be passed the original object as well as a ` * mut c_void ` which will point to the capsule ' s context if any .
pub fn new_with_destructor<
        'py,
        T: 'static + Send + AssertNotZeroSized,
        F: FnOnce(T, *mut c_void),
    >(
        py: Python<'py>,
        value: T,
        name: &CStr,
        destructor: F,
    ) -> PyResult<&'py Self> {
        AssertNotZeroSized::assert_not_zero_sized(&value);
        let val = Box::new(CapsuleContents { value, destructor });
        let cap_ptr = unsafe {
            ffi::PyCapsule_New(
                Box::into_raw(val) as *mut c_void,
                name.as_ptr(),
                Some(capsule_destructor::<T, F>),
            )
        };
        unsafe { py.from_owned_ptr_or_err(cap_ptr) }
    }
pub fn new_with_destructor < ' py , T : ' static + Send + AssertNotZeroSized , F : FnOnce ( T , * mut c_void ) , > ( py : Python < ' py > , value : T , name : & CStr , destructor : F , ) -> PyResult < & ' py Self > { AssertNotZeroSized :: assert_not_zero_sized ( & value ) ; let val = Box :: new ( CapsuleContents { value , destructor } ) ; let cap_ptr = unsafe { ffi :: PyCapsule_New ( Box :: into_raw ( val ) as * mut c_void , name . as_ptr ( ) , Some ( capsule_destructor :: < T , F > ) , ) } ; unsafe { py . from_owned_ptr_or_err ( cap_ptr ) } }
Constructs a new capsule whose contents are `value`, associated with `name`.
Constructs a new capsule whose contents are ` value ` associated with ` name ` .
py
Python<'py>
value
T
name
&CStr
destructor
F
py
Python<'py>
value
T
name
&CStr
destructor
F