Merge pull request #615 from PyO3/fix-specialization
Fix broken specialized implementations with Rust 1.40
This commit is contained in:
commit
d602b65347
|
@ -10,6 +10,7 @@ and this project adheres to [Semantic Versioning](http://semver.org/spec/v2.0.0.
|
|||
### Fixed
|
||||
|
||||
* Make sure the right Python interpreter is used in OSX builds. [#604](https://github.com/PyO3/pyo3/pull/604)
|
||||
* Patch specialization being broken by Rust 1.40 [#614](https://github.com/PyO3/pyo3/issues/614)
|
||||
|
||||
## [0.8.0] - 2018-09-05
|
||||
|
||||
|
|
|
@ -38,7 +38,7 @@ pub fn gen_py_method(
|
|||
return Err(syn::Error::new_spanned(
|
||||
spec.args[0].ty,
|
||||
"Getter function can only have one argument of type pyo3::Python!",
|
||||
))
|
||||
));
|
||||
}
|
||||
};
|
||||
impl_py_getter_def(name, doc, getter, &impl_wrap_getter(cls, name, takes_py))
|
||||
|
@ -60,10 +60,10 @@ fn check_generic(name: &syn::Ident, sig: &syn::Signature) -> syn::Result<()> {
|
|||
match param {
|
||||
syn::GenericParam::Lifetime(_) => {}
|
||||
syn::GenericParam::Type(_) => {
|
||||
return Err(syn::Error::new_spanned(param, err_msg("type")))
|
||||
return Err(syn::Error::new_spanned(param, err_msg("type")));
|
||||
}
|
||||
syn::GenericParam::Const(_) => {
|
||||
return Err(syn::Error::new_spanned(param, err_msg("const")))
|
||||
return Err(syn::Error::new_spanned(param, err_msg("const")));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -152,17 +152,21 @@ pub trait PyObjectRichcmpProtocol<'p>: PyObjectProtocol<'p> {
|
|||
|
||||
#[doc(hidden)]
|
||||
pub trait PyObjectProtocolImpl {
|
||||
fn methods() -> Vec<PyMethodDef> {
|
||||
fn methods() -> Vec<PyMethodDef>;
|
||||
fn tp_as_object(_type_object: &mut ffi::PyTypeObject);
|
||||
fn nb_bool_fn() -> Option<ffi::inquiry>;
|
||||
}
|
||||
|
||||
impl<T> PyObjectProtocolImpl for T {
|
||||
default fn methods() -> Vec<PyMethodDef> {
|
||||
Vec::new()
|
||||
}
|
||||
fn tp_as_object(_type_object: &mut ffi::PyTypeObject) {}
|
||||
fn nb_bool_fn() -> Option<ffi::inquiry> {
|
||||
default fn tp_as_object(_type_object: &mut ffi::PyTypeObject) {}
|
||||
default fn nb_bool_fn() -> Option<ffi::inquiry> {
|
||||
None
|
||||
}
|
||||
}
|
||||
|
||||
impl<T> PyObjectProtocolImpl for T {}
|
||||
|
||||
impl<'p, T> PyObjectProtocolImpl for T
|
||||
where
|
||||
T: PyObjectProtocol<'p>,
|
||||
|
@ -195,13 +199,18 @@ where
|
|||
}
|
||||
|
||||
trait GetAttrProtocolImpl {
|
||||
fn tp_getattro() -> Option<ffi::binaryfunc> {
|
||||
fn tp_getattro() -> Option<ffi::binaryfunc>;
|
||||
}
|
||||
|
||||
impl<'p, T> GetAttrProtocolImpl for T
|
||||
where
|
||||
T: PyObjectProtocol<'p>,
|
||||
{
|
||||
default fn tp_getattro() -> Option<ffi::binaryfunc> {
|
||||
None
|
||||
}
|
||||
}
|
||||
|
||||
impl<'p, T> GetAttrProtocolImpl for T where T: PyObjectProtocol<'p> {}
|
||||
|
||||
impl<T> GetAttrProtocolImpl for T
|
||||
where
|
||||
T: for<'p> PyObjectGetAttrProtocol<'p>,
|
||||
|
@ -268,13 +277,15 @@ mod tp_setattro_impl {
|
|||
}
|
||||
|
||||
trait SetAttr {
|
||||
fn set_attr() -> Option<ffi::setattrofunc> {
|
||||
fn set_attr() -> Option<ffi::setattrofunc>;
|
||||
}
|
||||
|
||||
impl<'p, T: PyObjectProtocol<'p>> SetAttr for T {
|
||||
default fn set_attr() -> Option<ffi::setattrofunc> {
|
||||
None
|
||||
}
|
||||
}
|
||||
|
||||
impl<'p, T: PyObjectProtocol<'p>> SetAttr for T {}
|
||||
|
||||
impl<T> SetAttr for T
|
||||
where
|
||||
T: for<'p> PyObjectSetAttrProtocol<'p>,
|
||||
|
@ -285,13 +296,18 @@ mod tp_setattro_impl {
|
|||
}
|
||||
|
||||
trait DelAttr {
|
||||
fn del_attr() -> Option<ffi::setattrofunc> {
|
||||
fn del_attr() -> Option<ffi::setattrofunc>;
|
||||
}
|
||||
|
||||
impl<'p, T> DelAttr for T
|
||||
where
|
||||
T: PyObjectProtocol<'p>,
|
||||
{
|
||||
default fn del_attr() -> Option<ffi::setattrofunc> {
|
||||
None
|
||||
}
|
||||
}
|
||||
|
||||
impl<'p, T> DelAttr for T where T: PyObjectProtocol<'p> {}
|
||||
|
||||
impl<T> DelAttr for T
|
||||
where
|
||||
T: for<'p> PyObjectDelAttrProtocol<'p>,
|
||||
|
@ -302,13 +318,18 @@ mod tp_setattro_impl {
|
|||
}
|
||||
|
||||
trait SetDelAttr {
|
||||
fn set_del_attr() -> Option<ffi::setattrofunc> {
|
||||
fn set_del_attr() -> Option<ffi::setattrofunc>;
|
||||
}
|
||||
|
||||
impl<'p, T> SetDelAttr for T
|
||||
where
|
||||
T: PyObjectProtocol<'p>,
|
||||
{
|
||||
default fn set_del_attr() -> Option<ffi::setattrofunc> {
|
||||
None
|
||||
}
|
||||
}
|
||||
|
||||
impl<'p, T> SetDelAttr for T where T: PyObjectProtocol<'p> {}
|
||||
|
||||
impl<T> SetDelAttr for T
|
||||
where
|
||||
T: for<'p> PyObjectSetAttrProtocol<'p> + for<'p> PyObjectDelAttrProtocol<'p>,
|
||||
|
@ -326,11 +347,16 @@ mod tp_setattro_impl {
|
|||
}
|
||||
|
||||
trait StrProtocolImpl {
|
||||
fn tp_str() -> Option<ffi::unaryfunc> {
|
||||
fn tp_str() -> Option<ffi::unaryfunc>;
|
||||
}
|
||||
impl<'p, T> StrProtocolImpl for T
|
||||
where
|
||||
T: PyObjectProtocol<'p>,
|
||||
{
|
||||
default fn tp_str() -> Option<ffi::unaryfunc> {
|
||||
None
|
||||
}
|
||||
}
|
||||
impl<'p, T> StrProtocolImpl for T where T: PyObjectProtocol<'p> {}
|
||||
impl<T> StrProtocolImpl for T
|
||||
where
|
||||
T: for<'p> PyObjectStrProtocol<'p>,
|
||||
|
@ -346,11 +372,16 @@ where
|
|||
}
|
||||
|
||||
trait ReprProtocolImpl {
|
||||
fn tp_repr() -> Option<ffi::unaryfunc> {
|
||||
fn tp_repr() -> Option<ffi::unaryfunc>;
|
||||
}
|
||||
impl<'p, T> ReprProtocolImpl for T
|
||||
where
|
||||
T: PyObjectProtocol<'p>,
|
||||
{
|
||||
default fn tp_repr() -> Option<ffi::unaryfunc> {
|
||||
None
|
||||
}
|
||||
}
|
||||
impl<'p, T> ReprProtocolImpl for T where T: PyObjectProtocol<'p> {}
|
||||
impl<T> ReprProtocolImpl for T
|
||||
where
|
||||
T: for<'p> PyObjectReprProtocol<'p>,
|
||||
|
@ -367,34 +398,54 @@ where
|
|||
|
||||
#[doc(hidden)]
|
||||
pub trait FormatProtocolImpl {
|
||||
fn __format__() -> Option<PyMethodDef> {
|
||||
fn __format__() -> Option<PyMethodDef>;
|
||||
}
|
||||
impl<'p, T> FormatProtocolImpl for T
|
||||
where
|
||||
T: PyObjectProtocol<'p>,
|
||||
{
|
||||
default fn __format__() -> Option<PyMethodDef> {
|
||||
None
|
||||
}
|
||||
}
|
||||
impl<'p, T> FormatProtocolImpl for T where T: PyObjectProtocol<'p> {}
|
||||
|
||||
#[doc(hidden)]
|
||||
pub trait BytesProtocolImpl {
|
||||
fn __bytes__() -> Option<PyMethodDef> {
|
||||
fn __bytes__() -> Option<PyMethodDef>;
|
||||
}
|
||||
impl<'p, T> BytesProtocolImpl for T
|
||||
where
|
||||
T: PyObjectProtocol<'p>,
|
||||
{
|
||||
default fn __bytes__() -> Option<PyMethodDef> {
|
||||
None
|
||||
}
|
||||
}
|
||||
impl<'p, T> BytesProtocolImpl for T where T: PyObjectProtocol<'p> {}
|
||||
|
||||
#[doc(hidden)]
|
||||
pub trait UnicodeProtocolImpl {
|
||||
fn __unicode__() -> Option<PyMethodDef> {
|
||||
fn __unicode__() -> Option<PyMethodDef>;
|
||||
}
|
||||
impl<'p, T> UnicodeProtocolImpl for T
|
||||
where
|
||||
T: PyObjectProtocol<'p>,
|
||||
{
|
||||
default fn __unicode__() -> Option<PyMethodDef> {
|
||||
None
|
||||
}
|
||||
}
|
||||
impl<'p, T> UnicodeProtocolImpl for T where T: PyObjectProtocol<'p> {}
|
||||
|
||||
trait HashProtocolImpl {
|
||||
fn tp_hash() -> Option<ffi::hashfunc> {
|
||||
fn tp_hash() -> Option<ffi::hashfunc>;
|
||||
}
|
||||
impl<'p, T> HashProtocolImpl for T
|
||||
where
|
||||
T: PyObjectProtocol<'p>,
|
||||
{
|
||||
default fn tp_hash() -> Option<ffi::hashfunc> {
|
||||
None
|
||||
}
|
||||
}
|
||||
impl<'p, T> HashProtocolImpl for T where T: PyObjectProtocol<'p> {}
|
||||
impl<T> HashProtocolImpl for T
|
||||
where
|
||||
T: for<'p> PyObjectHashProtocol<'p>,
|
||||
|
@ -411,11 +462,16 @@ where
|
|||
}
|
||||
|
||||
trait BoolProtocolImpl {
|
||||
fn nb_bool() -> Option<ffi::inquiry> {
|
||||
fn nb_bool() -> Option<ffi::inquiry>;
|
||||
}
|
||||
impl<'p, T> BoolProtocolImpl for T
|
||||
where
|
||||
T: PyObjectProtocol<'p>,
|
||||
{
|
||||
default fn nb_bool() -> Option<ffi::inquiry> {
|
||||
None
|
||||
}
|
||||
}
|
||||
impl<'p, T> BoolProtocolImpl for T where T: PyObjectProtocol<'p> {}
|
||||
impl<T> BoolProtocolImpl for T
|
||||
where
|
||||
T: for<'p> PyObjectBoolProtocol<'p>,
|
||||
|
@ -432,11 +488,16 @@ where
|
|||
}
|
||||
|
||||
trait RichcmpProtocolImpl {
|
||||
fn tp_richcompare() -> Option<ffi::richcmpfunc> {
|
||||
fn tp_richcompare() -> Option<ffi::richcmpfunc>;
|
||||
}
|
||||
impl<'p, T> RichcmpProtocolImpl for T
|
||||
where
|
||||
T: PyObjectProtocol<'p>,
|
||||
{
|
||||
default fn tp_richcompare() -> Option<ffi::richcmpfunc> {
|
||||
None
|
||||
}
|
||||
}
|
||||
impl<'p, T> RichcmpProtocolImpl for T where T: PyObjectProtocol<'p> {}
|
||||
impl<T> RichcmpProtocolImpl for T
|
||||
where
|
||||
T: for<'p> PyObjectRichcmpProtocol<'p>,
|
||||
|
|
|
@ -41,13 +41,15 @@ pub trait PyBufferReleaseBufferProtocol<'p>: PyBufferProtocol<'p> {
|
|||
|
||||
#[doc(hidden)]
|
||||
pub trait PyBufferProtocolImpl {
|
||||
fn tp_as_buffer() -> Option<ffi::PyBufferProcs> {
|
||||
fn tp_as_buffer() -> Option<ffi::PyBufferProcs>;
|
||||
}
|
||||
|
||||
impl<T> PyBufferProtocolImpl for T {
|
||||
default fn tp_as_buffer() -> Option<ffi::PyBufferProcs> {
|
||||
None
|
||||
}
|
||||
}
|
||||
|
||||
impl<T> PyBufferProtocolImpl for T {}
|
||||
|
||||
impl<'p, T> PyBufferProtocolImpl for T
|
||||
where
|
||||
T: PyBufferProtocol<'p>,
|
||||
|
@ -64,13 +66,18 @@ where
|
|||
}
|
||||
|
||||
trait PyBufferGetBufferProtocolImpl {
|
||||
fn cb_bf_getbuffer() -> Option<ffi::getbufferproc> {
|
||||
fn cb_bf_getbuffer() -> Option<ffi::getbufferproc>;
|
||||
}
|
||||
|
||||
impl<'p, T> PyBufferGetBufferProtocolImpl for T
|
||||
where
|
||||
T: PyBufferProtocol<'p>,
|
||||
{
|
||||
default fn cb_bf_getbuffer() -> Option<ffi::getbufferproc> {
|
||||
None
|
||||
}
|
||||
}
|
||||
|
||||
impl<'p, T> PyBufferGetBufferProtocolImpl for T where T: PyBufferProtocol<'p> {}
|
||||
|
||||
impl<T> PyBufferGetBufferProtocolImpl for T
|
||||
where
|
||||
T: for<'p> PyBufferGetBufferProtocol<'p>,
|
||||
|
|
|
@ -47,13 +47,15 @@ pub trait PyContextExitProtocol<'p>: PyContextProtocol<'p> {
|
|||
|
||||
#[doc(hidden)]
|
||||
pub trait PyContextProtocolImpl {
|
||||
fn methods() -> Vec<PyMethodDef> {
|
||||
fn methods() -> Vec<PyMethodDef>;
|
||||
}
|
||||
|
||||
impl<T> PyContextProtocolImpl for T {
|
||||
default fn methods() -> Vec<PyMethodDef> {
|
||||
Vec::new()
|
||||
}
|
||||
}
|
||||
|
||||
impl<T> PyContextProtocolImpl for T {}
|
||||
|
||||
impl<'p, T> PyContextProtocolImpl for T
|
||||
where
|
||||
T: PyContextProtocol<'p>,
|
||||
|
@ -75,18 +77,28 @@ where
|
|||
|
||||
#[doc(hidden)]
|
||||
pub trait PyContextEnterProtocolImpl {
|
||||
fn __enter__() -> Option<PyMethodDef> {
|
||||
fn __enter__() -> Option<PyMethodDef>;
|
||||
}
|
||||
|
||||
impl<'p, T> PyContextEnterProtocolImpl for T
|
||||
where
|
||||
T: PyContextProtocol<'p>,
|
||||
{
|
||||
default fn __enter__() -> Option<PyMethodDef> {
|
||||
None
|
||||
}
|
||||
}
|
||||
|
||||
impl<'p, T> PyContextEnterProtocolImpl for T where T: PyContextProtocol<'p> {}
|
||||
|
||||
#[doc(hidden)]
|
||||
pub trait PyContextExitProtocolImpl {
|
||||
fn __exit__() -> Option<PyMethodDef> {
|
||||
fn __exit__() -> Option<PyMethodDef>;
|
||||
}
|
||||
|
||||
impl<'p, T> PyContextExitProtocolImpl for T
|
||||
where
|
||||
T: PyContextProtocol<'p>,
|
||||
{
|
||||
default fn __exit__() -> Option<PyMethodDef> {
|
||||
None
|
||||
}
|
||||
}
|
||||
|
||||
impl<'p, T> PyContextExitProtocolImpl for T where T: PyContextProtocol<'p> {}
|
||||
|
|
|
@ -70,11 +70,16 @@ pub trait PyDescrSetNameProtocol<'p>: PyDescrProtocol<'p> {
|
|||
}
|
||||
|
||||
trait PyDescrGetProtocolImpl {
|
||||
fn tp_descr_get() -> Option<ffi::descrgetfunc> {
|
||||
fn tp_descr_get() -> Option<ffi::descrgetfunc>;
|
||||
}
|
||||
impl<'p, T> PyDescrGetProtocolImpl for T
|
||||
where
|
||||
T: PyDescrProtocol<'p>,
|
||||
{
|
||||
default fn tp_descr_get() -> Option<ffi::descrgetfunc> {
|
||||
None
|
||||
}
|
||||
}
|
||||
impl<'p, T> PyDescrGetProtocolImpl for T where T: PyDescrProtocol<'p> {}
|
||||
|
||||
impl<T> PyDescrGetProtocolImpl for T
|
||||
where
|
||||
|
@ -91,11 +96,16 @@ where
|
|||
}
|
||||
|
||||
trait PyDescrSetProtocolImpl {
|
||||
fn tp_descr_set() -> Option<ffi::descrsetfunc> {
|
||||
fn tp_descr_set() -> Option<ffi::descrsetfunc>;
|
||||
}
|
||||
impl<'p, T> PyDescrSetProtocolImpl for T
|
||||
where
|
||||
T: PyDescrProtocol<'p>,
|
||||
{
|
||||
default fn tp_descr_set() -> Option<ffi::descrsetfunc> {
|
||||
None
|
||||
}
|
||||
}
|
||||
impl<'p, T> PyDescrSetProtocolImpl for T where T: PyDescrProtocol<'p> {}
|
||||
impl<T> PyDescrSetProtocolImpl for T
|
||||
where
|
||||
T: for<'p> PyDescrSetProtocol<'p>,
|
||||
|
@ -127,13 +137,16 @@ impl<'p, T> PyDescrSetNameProtocolImpl for T where T: PyDescrProtocol<'p> {}
|
|||
|
||||
#[doc(hidden)]
|
||||
pub trait PyDescrProtocolImpl {
|
||||
fn methods() -> Vec<PyMethodDef> {
|
||||
Vec::new()
|
||||
}
|
||||
fn tp_as_descr(_type_object: &mut ffi::PyTypeObject) {}
|
||||
fn methods() -> Vec<PyMethodDef>;
|
||||
fn tp_as_descr(_type_object: &mut ffi::PyTypeObject);
|
||||
}
|
||||
|
||||
impl<T> PyDescrProtocolImpl for T {}
|
||||
impl<T> PyDescrProtocolImpl for T {
|
||||
default fn methods() -> Vec<PyMethodDef> {
|
||||
Vec::new()
|
||||
}
|
||||
default fn tp_as_descr(_type_object: &mut ffi::PyTypeObject) {}
|
||||
}
|
||||
|
||||
impl<'p, T> PyDescrProtocolImpl for T
|
||||
where
|
||||
|
|
|
@ -23,10 +23,12 @@ pub trait PyGCClearProtocol<'p>: PyGCProtocol<'p> {}
|
|||
|
||||
#[doc(hidden)]
|
||||
pub trait PyGCProtocolImpl {
|
||||
fn update_type_object(_type_object: &mut ffi::PyTypeObject) {}
|
||||
fn update_type_object(_type_object: &mut ffi::PyTypeObject);
|
||||
}
|
||||
|
||||
impl<'p, T> PyGCProtocolImpl for T {}
|
||||
impl<'p, T> PyGCProtocolImpl for T {
|
||||
default fn update_type_object(_type_object: &mut ffi::PyTypeObject) {}
|
||||
}
|
||||
|
||||
impl<'p, T> PyGCProtocolImpl for T
|
||||
where
|
||||
|
@ -63,13 +65,18 @@ impl<'p> PyVisit<'p> {
|
|||
}
|
||||
|
||||
trait PyGCTraverseProtocolImpl {
|
||||
fn tp_traverse() -> Option<ffi::traverseproc> {
|
||||
fn tp_traverse() -> Option<ffi::traverseproc>;
|
||||
}
|
||||
|
||||
impl<'p, T> PyGCTraverseProtocolImpl for T
|
||||
where
|
||||
T: PyGCProtocol<'p>,
|
||||
{
|
||||
default fn tp_traverse() -> Option<ffi::traverseproc> {
|
||||
None
|
||||
}
|
||||
}
|
||||
|
||||
impl<'p, T> PyGCTraverseProtocolImpl for T where T: PyGCProtocol<'p> {}
|
||||
|
||||
#[doc(hidden)]
|
||||
impl<T> PyGCTraverseProtocolImpl for T
|
||||
where
|
||||
|
@ -105,13 +112,18 @@ where
|
|||
}
|
||||
|
||||
trait PyGCClearProtocolImpl {
|
||||
fn tp_clear() -> Option<ffi::inquiry> {
|
||||
fn tp_clear() -> Option<ffi::inquiry>;
|
||||
}
|
||||
|
||||
impl<'p, T> PyGCClearProtocolImpl for T
|
||||
where
|
||||
T: PyGCProtocol<'p>,
|
||||
{
|
||||
default fn tp_clear() -> Option<ffi::inquiry> {
|
||||
None
|
||||
}
|
||||
}
|
||||
|
||||
impl<'p, T> PyGCClearProtocolImpl for T where T: PyGCProtocol<'p> {}
|
||||
|
||||
impl<T> PyGCClearProtocolImpl for T
|
||||
where
|
||||
T: for<'p> PyGCClearProtocol<'p>,
|
||||
|
|
|
@ -44,10 +44,12 @@ pub trait PyIterNextProtocol<'p>: PyIterProtocol<'p> {
|
|||
|
||||
#[doc(hidden)]
|
||||
pub trait PyIterProtocolImpl {
|
||||
fn tp_as_iter(_typeob: &mut ffi::PyTypeObject) {}
|
||||
fn tp_as_iter(_typeob: &mut ffi::PyTypeObject);
|
||||
}
|
||||
|
||||
impl<T> PyIterProtocolImpl for T {}
|
||||
impl<T> PyIterProtocolImpl for T {
|
||||
default fn tp_as_iter(_typeob: &mut ffi::PyTypeObject) {}
|
||||
}
|
||||
|
||||
impl<'p, T> PyIterProtocolImpl for T
|
||||
where
|
||||
|
@ -61,13 +63,18 @@ where
|
|||
}
|
||||
|
||||
trait PyIterIterProtocolImpl {
|
||||
fn tp_iter() -> Option<ffi::getiterfunc> {
|
||||
fn tp_iter() -> Option<ffi::getiterfunc>;
|
||||
}
|
||||
|
||||
impl<'p, T> PyIterIterProtocolImpl for T
|
||||
where
|
||||
T: PyIterProtocol<'p>,
|
||||
{
|
||||
default fn tp_iter() -> Option<ffi::getiterfunc> {
|
||||
None
|
||||
}
|
||||
}
|
||||
|
||||
impl<'p, T> PyIterIterProtocolImpl for T where T: PyIterProtocol<'p> {}
|
||||
|
||||
impl<T> PyIterIterProtocolImpl for T
|
||||
where
|
||||
T: for<'p> PyIterIterProtocol<'p>,
|
||||
|
@ -84,13 +91,18 @@ where
|
|||
}
|
||||
|
||||
trait PyIterNextProtocolImpl {
|
||||
fn tp_iternext() -> Option<ffi::iternextfunc> {
|
||||
fn tp_iternext() -> Option<ffi::iternextfunc>;
|
||||
}
|
||||
|
||||
impl<'p, T> PyIterNextProtocolImpl for T
|
||||
where
|
||||
T: PyIterProtocol<'p>,
|
||||
{
|
||||
default fn tp_iternext() -> Option<ffi::iternextfunc> {
|
||||
None
|
||||
}
|
||||
}
|
||||
|
||||
impl<'p, T> PyIterNextProtocolImpl for T where T: PyIterProtocol<'p> {}
|
||||
|
||||
impl<T> PyIterNextProtocolImpl for T
|
||||
where
|
||||
T: for<'p> PyIterNextProtocol<'p>,
|
||||
|
|
|
@ -106,16 +106,19 @@ pub trait PyMappingReversedProtocol<'p>: PyMappingProtocol<'p> {
|
|||
|
||||
#[doc(hidden)]
|
||||
pub trait PyMappingProtocolImpl {
|
||||
fn tp_as_mapping() -> Option<ffi::PyMappingMethods> {
|
||||
fn tp_as_mapping() -> Option<ffi::PyMappingMethods>;
|
||||
fn methods() -> Vec<PyMethodDef>;
|
||||
}
|
||||
|
||||
impl<T> PyMappingProtocolImpl for T {
|
||||
default fn tp_as_mapping() -> Option<ffi::PyMappingMethods> {
|
||||
None
|
||||
}
|
||||
fn methods() -> Vec<PyMethodDef> {
|
||||
default fn methods() -> Vec<PyMethodDef> {
|
||||
Vec::new()
|
||||
}
|
||||
}
|
||||
|
||||
impl<T> PyMappingProtocolImpl for T {}
|
||||
|
||||
impl<'p, T> PyMappingProtocolImpl for T
|
||||
where
|
||||
T: PyMappingProtocol<'p>,
|
||||
|
@ -154,13 +157,18 @@ where
|
|||
}
|
||||
|
||||
trait PyMappingLenProtocolImpl {
|
||||
fn mp_length() -> Option<ffi::lenfunc> {
|
||||
fn mp_length() -> Option<ffi::lenfunc>;
|
||||
}
|
||||
|
||||
impl<'p, T> PyMappingLenProtocolImpl for T
|
||||
where
|
||||
T: PyMappingProtocol<'p>,
|
||||
{
|
||||
default fn mp_length() -> Option<ffi::lenfunc> {
|
||||
None
|
||||
}
|
||||
}
|
||||
|
||||
impl<'p, T> PyMappingLenProtocolImpl for T where T: PyMappingProtocol<'p> {}
|
||||
|
||||
impl<T> PyMappingLenProtocolImpl for T
|
||||
where
|
||||
T: for<'p> PyMappingLenProtocol<'p>,
|
||||
|
@ -172,13 +180,18 @@ where
|
|||
}
|
||||
|
||||
trait PyMappingGetItemProtocolImpl {
|
||||
fn mp_subscript() -> Option<ffi::binaryfunc> {
|
||||
fn mp_subscript() -> Option<ffi::binaryfunc>;
|
||||
}
|
||||
|
||||
impl<'p, T> PyMappingGetItemProtocolImpl for T
|
||||
where
|
||||
T: PyMappingProtocol<'p>,
|
||||
{
|
||||
default fn mp_subscript() -> Option<ffi::binaryfunc> {
|
||||
None
|
||||
}
|
||||
}
|
||||
|
||||
impl<'p, T> PyMappingGetItemProtocolImpl for T where T: PyMappingProtocol<'p> {}
|
||||
|
||||
impl<T> PyMappingGetItemProtocolImpl for T
|
||||
where
|
||||
T: for<'p> PyMappingGetItemProtocol<'p>,
|
||||
|
@ -195,13 +208,18 @@ where
|
|||
}
|
||||
|
||||
trait PyMappingSetItemProtocolImpl {
|
||||
fn mp_ass_subscript() -> Option<ffi::objobjargproc> {
|
||||
fn mp_ass_subscript() -> Option<ffi::objobjargproc>;
|
||||
}
|
||||
|
||||
impl<'p, T> PyMappingSetItemProtocolImpl for T
|
||||
where
|
||||
T: PyMappingProtocol<'p>,
|
||||
{
|
||||
default fn mp_ass_subscript() -> Option<ffi::objobjargproc> {
|
||||
None
|
||||
}
|
||||
}
|
||||
|
||||
impl<'p, T> PyMappingSetItemProtocolImpl for T where T: PyMappingProtocol<'p> {}
|
||||
|
||||
impl<T> PyMappingSetItemProtocolImpl for T
|
||||
where
|
||||
T: for<'p> PyMappingSetItemProtocol<'p>,
|
||||
|
@ -215,22 +233,32 @@ where
|
|||
/// Returns `None` if PyMappingDelItemProtocol isn't implemented, otherwise dispatches to
|
||||
/// `DelSetItemDispatch`
|
||||
trait DeplItemDipatch {
|
||||
fn mp_del_subscript() -> Option<ffi::objobjargproc> {
|
||||
fn mp_del_subscript() -> Option<ffi::objobjargproc>;
|
||||
}
|
||||
|
||||
impl<'p, T> DeplItemDipatch for T
|
||||
where
|
||||
T: PyMappingProtocol<'p>,
|
||||
{
|
||||
default fn mp_del_subscript() -> Option<ffi::objobjargproc> {
|
||||
None
|
||||
}
|
||||
}
|
||||
|
||||
impl<'p, T> DeplItemDipatch for T where T: PyMappingProtocol<'p> {}
|
||||
|
||||
/// Returns `py_func_set_del` if PyMappingSetItemProtocol is implemented, otherwise `py_func_del`
|
||||
trait DelSetItemDispatch: Sized + for<'p> PyMappingDelItemProtocol<'p> {
|
||||
fn det_set_dispatch() -> Option<ffi::objobjargproc> {
|
||||
fn det_set_dispatch() -> Option<ffi::objobjargproc>;
|
||||
}
|
||||
|
||||
impl<T> DelSetItemDispatch for T
|
||||
where
|
||||
T: Sized + for<'p> PyMappingDelItemProtocol<'p>,
|
||||
{
|
||||
default fn det_set_dispatch() -> Option<ffi::objobjargproc> {
|
||||
py_func_del!(PyMappingDelItemProtocol, Self, __delitem__)
|
||||
}
|
||||
}
|
||||
|
||||
impl<T> DelSetItemDispatch for T where T: Sized + for<'p> PyMappingDelItemProtocol<'p> {}
|
||||
|
||||
impl<T> DelSetItemDispatch for T
|
||||
where
|
||||
T: for<'p> PyMappingSetItemProtocol<'p> + for<'p> PyMappingDelItemProtocol<'p>,
|
||||
|
@ -257,27 +285,42 @@ where
|
|||
|
||||
#[doc(hidden)]
|
||||
pub trait PyMappingContainsProtocolImpl {
|
||||
fn __contains__() -> Option<PyMethodDef> {
|
||||
fn __contains__() -> Option<PyMethodDef>;
|
||||
}
|
||||
|
||||
impl<'p, T> PyMappingContainsProtocolImpl for T
|
||||
where
|
||||
T: PyMappingProtocol<'p>,
|
||||
{
|
||||
default fn __contains__() -> Option<PyMethodDef> {
|
||||
None
|
||||
}
|
||||
}
|
||||
|
||||
impl<'p, T> PyMappingContainsProtocolImpl for T where T: PyMappingProtocol<'p> {}
|
||||
|
||||
#[doc(hidden)]
|
||||
pub trait PyMappingReversedProtocolImpl {
|
||||
fn __reversed__() -> Option<PyMethodDef> {
|
||||
fn __reversed__() -> Option<PyMethodDef>;
|
||||
}
|
||||
|
||||
impl<'p, T> PyMappingReversedProtocolImpl for T
|
||||
where
|
||||
T: PyMappingProtocol<'p>,
|
||||
{
|
||||
default fn __reversed__() -> Option<PyMethodDef> {
|
||||
None
|
||||
}
|
||||
}
|
||||
|
||||
impl<'p, T> PyMappingReversedProtocolImpl for T where T: PyMappingProtocol<'p> {}
|
||||
|
||||
#[doc(hidden)]
|
||||
pub trait PyMappingIterProtocolImpl {
|
||||
fn __iter__() -> Option<PyMethodDef> {
|
||||
fn __iter__() -> Option<PyMethodDef>;
|
||||
}
|
||||
|
||||
impl<'p, T> PyMappingIterProtocolImpl for T
|
||||
where
|
||||
T: PyMappingProtocol<'p>,
|
||||
{
|
||||
default fn __iter__() -> Option<PyMethodDef> {
|
||||
None
|
||||
}
|
||||
}
|
||||
|
||||
impl<'p, T> PyMappingIterProtocolImpl for T where T: PyMappingProtocol<'p> {}
|
||||
|
|
|
@ -622,10 +622,15 @@ pub trait PyNumberIndexProtocol<'p>: PyNumberProtocol<'p> {
|
|||
|
||||
#[doc(hidden)]
|
||||
pub trait PyNumberProtocolImpl: PyObjectProtocolImpl {
|
||||
fn methods() -> Vec<PyMethodDef> {
|
||||
fn methods() -> Vec<PyMethodDef>;
|
||||
fn tp_as_number() -> Option<ffi::PyNumberMethods>;
|
||||
}
|
||||
|
||||
impl<'p, T> PyNumberProtocolImpl for T {
|
||||
default fn methods() -> Vec<PyMethodDef> {
|
||||
Vec::new()
|
||||
}
|
||||
fn tp_as_number() -> Option<ffi::PyNumberMethods> {
|
||||
default fn tp_as_number() -> Option<ffi::PyNumberMethods> {
|
||||
if let Some(nb_bool) = <Self as PyObjectProtocolImpl>::nb_bool_fn() {
|
||||
let meth = ffi::PyNumberMethods {
|
||||
nb_bool: Some(nb_bool),
|
||||
|
@ -638,8 +643,6 @@ pub trait PyNumberProtocolImpl: PyObjectProtocolImpl {
|
|||
}
|
||||
}
|
||||
|
||||
impl<'p, T> PyNumberProtocolImpl for T {}
|
||||
|
||||
impl<'p, T> PyNumberProtocolImpl for T
|
||||
where
|
||||
T: PyNumberProtocol<'p>,
|
||||
|
@ -743,13 +746,18 @@ where
|
|||
}
|
||||
|
||||
trait PyNumberAddProtocolImpl {
|
||||
fn nb_add() -> Option<ffi::binaryfunc> {
|
||||
fn nb_add() -> Option<ffi::binaryfunc>;
|
||||
}
|
||||
|
||||
impl<'p, T> PyNumberAddProtocolImpl for T
|
||||
where
|
||||
T: PyNumberProtocol<'p>,
|
||||
{
|
||||
default fn nb_add() -> Option<ffi::binaryfunc> {
|
||||
None
|
||||
}
|
||||
}
|
||||
|
||||
impl<'p, T> PyNumberAddProtocolImpl for T where T: PyNumberProtocol<'p> {}
|
||||
|
||||
impl<T> PyNumberAddProtocolImpl for T
|
||||
where
|
||||
T: for<'p> PyNumberAddProtocol<'p>,
|
||||
|
@ -765,13 +773,18 @@ where
|
|||
}
|
||||
|
||||
trait PyNumberSubProtocolImpl {
|
||||
fn nb_subtract() -> Option<ffi::binaryfunc> {
|
||||
fn nb_subtract() -> Option<ffi::binaryfunc>;
|
||||
}
|
||||
|
||||
impl<'p, T> PyNumberSubProtocolImpl for T
|
||||
where
|
||||
T: PyNumberProtocol<'p>,
|
||||
{
|
||||
default fn nb_subtract() -> Option<ffi::binaryfunc> {
|
||||
None
|
||||
}
|
||||
}
|
||||
|
||||
impl<'p, T> PyNumberSubProtocolImpl for T where T: PyNumberProtocol<'p> {}
|
||||
|
||||
impl<T> PyNumberSubProtocolImpl for T
|
||||
where
|
||||
T: for<'p> PyNumberSubProtocol<'p>,
|
||||
|
@ -787,13 +800,18 @@ where
|
|||
}
|
||||
|
||||
trait PyNumberMulProtocolImpl {
|
||||
fn nb_multiply() -> Option<ffi::binaryfunc> {
|
||||
fn nb_multiply() -> Option<ffi::binaryfunc>;
|
||||
}
|
||||
|
||||
impl<'p, T> PyNumberMulProtocolImpl for T
|
||||
where
|
||||
T: PyNumberProtocol<'p>,
|
||||
{
|
||||
default fn nb_multiply() -> Option<ffi::binaryfunc> {
|
||||
None
|
||||
}
|
||||
}
|
||||
|
||||
impl<'p, T> PyNumberMulProtocolImpl for T where T: PyNumberProtocol<'p> {}
|
||||
|
||||
impl<T> PyNumberMulProtocolImpl for T
|
||||
where
|
||||
T: for<'p> PyNumberMulProtocol<'p>,
|
||||
|
@ -809,13 +827,18 @@ where
|
|||
}
|
||||
|
||||
trait PyNumberMatmulProtocolImpl {
|
||||
fn nb_matrix_multiply() -> Option<ffi::binaryfunc> {
|
||||
fn nb_matrix_multiply() -> Option<ffi::binaryfunc>;
|
||||
}
|
||||
|
||||
impl<'p, T> PyNumberMatmulProtocolImpl for T
|
||||
where
|
||||
T: PyNumberProtocol<'p>,
|
||||
{
|
||||
default fn nb_matrix_multiply() -> Option<ffi::binaryfunc> {
|
||||
None
|
||||
}
|
||||
}
|
||||
|
||||
impl<'p, T> PyNumberMatmulProtocolImpl for T where T: PyNumberProtocol<'p> {}
|
||||
|
||||
impl<T> PyNumberMatmulProtocolImpl for T
|
||||
where
|
||||
T: for<'p> PyNumberMatmulProtocol<'p>,
|
||||
|
@ -831,13 +854,18 @@ where
|
|||
}
|
||||
|
||||
trait PyNumberTruedivProtocolImpl {
|
||||
fn nb_true_divide() -> Option<ffi::binaryfunc> {
|
||||
fn nb_true_divide() -> Option<ffi::binaryfunc>;
|
||||
}
|
||||
|
||||
impl<'p, T> PyNumberTruedivProtocolImpl for T
|
||||
where
|
||||
T: PyNumberProtocol<'p>,
|
||||
{
|
||||
default fn nb_true_divide() -> Option<ffi::binaryfunc> {
|
||||
None
|
||||
}
|
||||
}
|
||||
|
||||
impl<'p, T> PyNumberTruedivProtocolImpl for T where T: PyNumberProtocol<'p> {}
|
||||
|
||||
impl<T> PyNumberTruedivProtocolImpl for T
|
||||
where
|
||||
T: for<'p> PyNumberTruedivProtocol<'p>,
|
||||
|
@ -853,13 +881,18 @@ where
|
|||
}
|
||||
|
||||
trait PyNumberFloordivProtocolImpl {
|
||||
fn nb_floor_divide() -> Option<ffi::binaryfunc> {
|
||||
fn nb_floor_divide() -> Option<ffi::binaryfunc>;
|
||||
}
|
||||
|
||||
impl<'p, T> PyNumberFloordivProtocolImpl for T
|
||||
where
|
||||
T: PyNumberProtocol<'p>,
|
||||
{
|
||||
default fn nb_floor_divide() -> Option<ffi::binaryfunc> {
|
||||
None
|
||||
}
|
||||
}
|
||||
|
||||
impl<'p, T> PyNumberFloordivProtocolImpl for T where T: PyNumberProtocol<'p> {}
|
||||
|
||||
impl<T> PyNumberFloordivProtocolImpl for T
|
||||
where
|
||||
T: for<'p> PyNumberFloordivProtocol<'p>,
|
||||
|
@ -875,13 +908,18 @@ where
|
|||
}
|
||||
|
||||
trait PyNumberModProtocolImpl {
|
||||
fn nb_remainder() -> Option<ffi::binaryfunc> {
|
||||
fn nb_remainder() -> Option<ffi::binaryfunc>;
|
||||
}
|
||||
|
||||
impl<'p, T> PyNumberModProtocolImpl for T
|
||||
where
|
||||
T: PyNumberProtocol<'p>,
|
||||
{
|
||||
default fn nb_remainder() -> Option<ffi::binaryfunc> {
|
||||
None
|
||||
}
|
||||
}
|
||||
|
||||
impl<'p, T> PyNumberModProtocolImpl for T where T: PyNumberProtocol<'p> {}
|
||||
|
||||
impl<T> PyNumberModProtocolImpl for T
|
||||
where
|
||||
T: for<'p> PyNumberModProtocol<'p>,
|
||||
|
@ -897,13 +935,18 @@ where
|
|||
}
|
||||
|
||||
trait PyNumberDivmodProtocolImpl {
|
||||
fn nb_divmod() -> Option<ffi::binaryfunc> {
|
||||
fn nb_divmod() -> Option<ffi::binaryfunc>;
|
||||
}
|
||||
|
||||
impl<'p, T> PyNumberDivmodProtocolImpl for T
|
||||
where
|
||||
T: PyNumberProtocol<'p>,
|
||||
{
|
||||
default fn nb_divmod() -> Option<ffi::binaryfunc> {
|
||||
None
|
||||
}
|
||||
}
|
||||
|
||||
impl<'p, T> PyNumberDivmodProtocolImpl for T where T: PyNumberProtocol<'p> {}
|
||||
|
||||
impl<T> PyNumberDivmodProtocolImpl for T
|
||||
where
|
||||
T: for<'p> PyNumberDivmodProtocol<'p>,
|
||||
|
@ -919,13 +962,18 @@ where
|
|||
}
|
||||
|
||||
trait PyNumberPowProtocolImpl {
|
||||
fn nb_power() -> Option<ffi::ternaryfunc> {
|
||||
fn nb_power() -> Option<ffi::ternaryfunc>;
|
||||
}
|
||||
|
||||
impl<'p, T> PyNumberPowProtocolImpl for T
|
||||
where
|
||||
T: PyNumberProtocol<'p>,
|
||||
{
|
||||
default fn nb_power() -> Option<ffi::ternaryfunc> {
|
||||
None
|
||||
}
|
||||
}
|
||||
|
||||
impl<'p, T> PyNumberPowProtocolImpl for T where T: PyNumberProtocol<'p> {}
|
||||
|
||||
impl<T> PyNumberPowProtocolImpl for T
|
||||
where
|
||||
T: for<'p> PyNumberPowProtocol<'p>,
|
||||
|
@ -941,13 +989,18 @@ where
|
|||
}
|
||||
|
||||
trait PyNumberLShiftProtocolImpl {
|
||||
fn nb_lshift() -> Option<ffi::binaryfunc> {
|
||||
fn nb_lshift() -> Option<ffi::binaryfunc>;
|
||||
}
|
||||
|
||||
impl<'p, T> PyNumberLShiftProtocolImpl for T
|
||||
where
|
||||
T: PyNumberProtocol<'p>,
|
||||
{
|
||||
default fn nb_lshift() -> Option<ffi::binaryfunc> {
|
||||
None
|
||||
}
|
||||
}
|
||||
|
||||
impl<'p, T> PyNumberLShiftProtocolImpl for T where T: PyNumberProtocol<'p> {}
|
||||
|
||||
impl<T> PyNumberLShiftProtocolImpl for T
|
||||
where
|
||||
T: for<'p> PyNumberLShiftProtocol<'p>,
|
||||
|
@ -963,13 +1016,18 @@ where
|
|||
}
|
||||
|
||||
trait PyNumberRShiftProtocolImpl {
|
||||
fn nb_rshift() -> Option<ffi::binaryfunc> {
|
||||
fn nb_rshift() -> Option<ffi::binaryfunc>;
|
||||
}
|
||||
|
||||
impl<'p, T> PyNumberRShiftProtocolImpl for T
|
||||
where
|
||||
T: PyNumberProtocol<'p>,
|
||||
{
|
||||
default fn nb_rshift() -> Option<ffi::binaryfunc> {
|
||||
None
|
||||
}
|
||||
}
|
||||
|
||||
impl<'p, T> PyNumberRShiftProtocolImpl for T where T: PyNumberProtocol<'p> {}
|
||||
|
||||
impl<T> PyNumberRShiftProtocolImpl for T
|
||||
where
|
||||
T: for<'p> PyNumberRShiftProtocol<'p>,
|
||||
|
@ -985,13 +1043,18 @@ where
|
|||
}
|
||||
|
||||
trait PyNumberAndProtocolImpl {
|
||||
fn nb_and() -> Option<ffi::binaryfunc> {
|
||||
fn nb_and() -> Option<ffi::binaryfunc>;
|
||||
}
|
||||
|
||||
impl<'p, T> PyNumberAndProtocolImpl for T
|
||||
where
|
||||
T: PyNumberProtocol<'p>,
|
||||
{
|
||||
default fn nb_and() -> Option<ffi::binaryfunc> {
|
||||
None
|
||||
}
|
||||
}
|
||||
|
||||
impl<'p, T> PyNumberAndProtocolImpl for T where T: PyNumberProtocol<'p> {}
|
||||
|
||||
impl<T> PyNumberAndProtocolImpl for T
|
||||
where
|
||||
T: for<'p> PyNumberAndProtocol<'p>,
|
||||
|
@ -1007,13 +1070,18 @@ where
|
|||
}
|
||||
|
||||
trait PyNumberXorProtocolImpl {
|
||||
fn nb_xor() -> Option<ffi::binaryfunc> {
|
||||
fn nb_xor() -> Option<ffi::binaryfunc>;
|
||||
}
|
||||
|
||||
impl<'p, T> PyNumberXorProtocolImpl for T
|
||||
where
|
||||
T: PyNumberProtocol<'p>,
|
||||
{
|
||||
default fn nb_xor() -> Option<ffi::binaryfunc> {
|
||||
None
|
||||
}
|
||||
}
|
||||
|
||||
impl<'p, T> PyNumberXorProtocolImpl for T where T: PyNumberProtocol<'p> {}
|
||||
|
||||
impl<T> PyNumberXorProtocolImpl for T
|
||||
where
|
||||
T: for<'p> PyNumberXorProtocol<'p>,
|
||||
|
@ -1029,13 +1097,18 @@ where
|
|||
}
|
||||
|
||||
trait PyNumberOrProtocolImpl {
|
||||
fn nb_or() -> Option<ffi::binaryfunc> {
|
||||
fn nb_or() -> Option<ffi::binaryfunc>;
|
||||
}
|
||||
|
||||
impl<'p, T> PyNumberOrProtocolImpl for T
|
||||
where
|
||||
T: PyNumberProtocol<'p>,
|
||||
{
|
||||
default fn nb_or() -> Option<ffi::binaryfunc> {
|
||||
None
|
||||
}
|
||||
}
|
||||
|
||||
impl<'p, T> PyNumberOrProtocolImpl for T where T: PyNumberProtocol<'p> {}
|
||||
|
||||
impl<T> PyNumberOrProtocolImpl for T
|
||||
where
|
||||
T: for<'p> PyNumberOrProtocol<'p>,
|
||||
|
@ -1051,13 +1124,18 @@ where
|
|||
}
|
||||
|
||||
trait PyNumberIAddProtocolImpl {
|
||||
fn nb_inplace_add() -> Option<ffi::binaryfunc> {
|
||||
fn nb_inplace_add() -> Option<ffi::binaryfunc>;
|
||||
}
|
||||
|
||||
impl<'p, T> PyNumberIAddProtocolImpl for T
|
||||
where
|
||||
T: PyNumberProtocol<'p>,
|
||||
{
|
||||
default fn nb_inplace_add() -> Option<ffi::binaryfunc> {
|
||||
None
|
||||
}
|
||||
}
|
||||
|
||||
impl<'p, T> PyNumberIAddProtocolImpl for T where T: PyNumberProtocol<'p> {}
|
||||
|
||||
impl<T> PyNumberIAddProtocolImpl for T
|
||||
where
|
||||
T: for<'p> PyNumberIAddProtocol<'p>,
|
||||
|
@ -1068,13 +1146,18 @@ where
|
|||
}
|
||||
|
||||
trait PyNumberISubProtocolImpl {
|
||||
fn nb_inplace_subtract() -> Option<ffi::binaryfunc> {
|
||||
fn nb_inplace_subtract() -> Option<ffi::binaryfunc>;
|
||||
}
|
||||
|
||||
impl<'p, T> PyNumberISubProtocolImpl for T
|
||||
where
|
||||
T: PyNumberProtocol<'p>,
|
||||
{
|
||||
default fn nb_inplace_subtract() -> Option<ffi::binaryfunc> {
|
||||
None
|
||||
}
|
||||
}
|
||||
|
||||
impl<'p, T> PyNumberISubProtocolImpl for T where T: PyNumberProtocol<'p> {}
|
||||
|
||||
impl<T> PyNumberISubProtocolImpl for T
|
||||
where
|
||||
T: for<'p> PyNumberISubProtocol<'p>,
|
||||
|
@ -1085,13 +1168,18 @@ where
|
|||
}
|
||||
|
||||
trait PyNumberIMulProtocolImpl {
|
||||
fn nb_inplace_multiply() -> Option<ffi::binaryfunc> {
|
||||
fn nb_inplace_multiply() -> Option<ffi::binaryfunc>;
|
||||
}
|
||||
|
||||
impl<'p, T> PyNumberIMulProtocolImpl for T
|
||||
where
|
||||
T: PyNumberProtocol<'p>,
|
||||
{
|
||||
default fn nb_inplace_multiply() -> Option<ffi::binaryfunc> {
|
||||
None
|
||||
}
|
||||
}
|
||||
|
||||
impl<'p, T> PyNumberIMulProtocolImpl for T where T: PyNumberProtocol<'p> {}
|
||||
|
||||
impl<T> PyNumberIMulProtocolImpl for T
|
||||
where
|
||||
T: for<'p> PyNumberIMulProtocol<'p>,
|
||||
|
@ -1102,13 +1190,18 @@ where
|
|||
}
|
||||
|
||||
trait PyNumberIMatmulProtocolImpl {
|
||||
fn nb_inplace_matrix_multiply() -> Option<ffi::binaryfunc> {
|
||||
fn nb_inplace_matrix_multiply() -> Option<ffi::binaryfunc>;
|
||||
}
|
||||
|
||||
impl<'p, T> PyNumberIMatmulProtocolImpl for T
|
||||
where
|
||||
T: PyNumberProtocol<'p>,
|
||||
{
|
||||
default fn nb_inplace_matrix_multiply() -> Option<ffi::binaryfunc> {
|
||||
None
|
||||
}
|
||||
}
|
||||
|
||||
impl<'p, T> PyNumberIMatmulProtocolImpl for T where T: PyNumberProtocol<'p> {}
|
||||
|
||||
impl<T> PyNumberIMatmulProtocolImpl for T
|
||||
where
|
||||
T: for<'p> PyNumberIMatmulProtocol<'p>,
|
||||
|
@ -1119,13 +1212,18 @@ where
|
|||
}
|
||||
|
||||
trait PyNumberITruedivProtocolImpl {
|
||||
fn nb_inplace_true_divide() -> Option<ffi::binaryfunc> {
|
||||
fn nb_inplace_true_divide() -> Option<ffi::binaryfunc>;
|
||||
}
|
||||
|
||||
impl<'p, T> PyNumberITruedivProtocolImpl for T
|
||||
where
|
||||
T: PyNumberProtocol<'p>,
|
||||
{
|
||||
default fn nb_inplace_true_divide() -> Option<ffi::binaryfunc> {
|
||||
None
|
||||
}
|
||||
}
|
||||
|
||||
impl<'p, T> PyNumberITruedivProtocolImpl for T where T: PyNumberProtocol<'p> {}
|
||||
|
||||
impl<T> PyNumberITruedivProtocolImpl for T
|
||||
where
|
||||
T: for<'p> PyNumberITruedivProtocol<'p>,
|
||||
|
@ -1136,13 +1234,18 @@ where
|
|||
}
|
||||
|
||||
trait PyNumberIFloordivProtocolImpl {
|
||||
fn nb_inplace_floor_divide() -> Option<ffi::binaryfunc> {
|
||||
fn nb_inplace_floor_divide() -> Option<ffi::binaryfunc>;
|
||||
}
|
||||
|
||||
impl<'p, T> PyNumberIFloordivProtocolImpl for T
|
||||
where
|
||||
T: PyNumberProtocol<'p>,
|
||||
{
|
||||
default fn nb_inplace_floor_divide() -> Option<ffi::binaryfunc> {
|
||||
None
|
||||
}
|
||||
}
|
||||
|
||||
impl<'p, T> PyNumberIFloordivProtocolImpl for T where T: PyNumberProtocol<'p> {}
|
||||
|
||||
impl<T> PyNumberIFloordivProtocolImpl for T
|
||||
where
|
||||
T: for<'p> PyNumberIFloordivProtocol<'p>,
|
||||
|
@ -1153,13 +1256,18 @@ where
|
|||
}
|
||||
|
||||
trait PyNumberIModProtocolImpl {
|
||||
fn nb_inplace_remainder() -> Option<ffi::binaryfunc> {
|
||||
fn nb_inplace_remainder() -> Option<ffi::binaryfunc>;
|
||||
}
|
||||
|
||||
impl<'p, T> PyNumberIModProtocolImpl for T
|
||||
where
|
||||
T: PyNumberProtocol<'p>,
|
||||
{
|
||||
default fn nb_inplace_remainder() -> Option<ffi::binaryfunc> {
|
||||
None
|
||||
}
|
||||
}
|
||||
|
||||
impl<'p, T> PyNumberIModProtocolImpl for T where T: PyNumberProtocol<'p> {}
|
||||
|
||||
impl<T> PyNumberIModProtocolImpl for T
|
||||
where
|
||||
T: for<'p> PyNumberIModProtocol<'p>,
|
||||
|
@ -1170,13 +1278,18 @@ where
|
|||
}
|
||||
|
||||
trait PyNumberIPowProtocolImpl {
|
||||
fn nb_inplace_power() -> Option<ffi::ternaryfunc> {
|
||||
fn nb_inplace_power() -> Option<ffi::ternaryfunc>;
|
||||
}
|
||||
|
||||
impl<'p, T> PyNumberIPowProtocolImpl for T
|
||||
where
|
||||
T: PyNumberProtocol<'p>,
|
||||
{
|
||||
default fn nb_inplace_power() -> Option<ffi::ternaryfunc> {
|
||||
None
|
||||
}
|
||||
}
|
||||
|
||||
impl<'p, T> PyNumberIPowProtocolImpl for T where T: PyNumberProtocol<'p> {}
|
||||
|
||||
impl<T> PyNumberIPowProtocolImpl for T
|
||||
where
|
||||
T: for<'p> PyNumberIPowProtocol<'p>,
|
||||
|
@ -1187,13 +1300,18 @@ where
|
|||
}
|
||||
|
||||
trait PyNumberILShiftProtocolImpl {
|
||||
fn nb_inplace_lshift() -> Option<ffi::binaryfunc> {
|
||||
fn nb_inplace_lshift() -> Option<ffi::binaryfunc>;
|
||||
}
|
||||
|
||||
impl<'p, T> PyNumberILShiftProtocolImpl for T
|
||||
where
|
||||
T: PyNumberProtocol<'p>,
|
||||
{
|
||||
default fn nb_inplace_lshift() -> Option<ffi::binaryfunc> {
|
||||
None
|
||||
}
|
||||
}
|
||||
|
||||
impl<'p, T> PyNumberILShiftProtocolImpl for T where T: PyNumberProtocol<'p> {}
|
||||
|
||||
impl<T> PyNumberILShiftProtocolImpl for T
|
||||
where
|
||||
T: for<'p> PyNumberILShiftProtocol<'p>,
|
||||
|
@ -1204,13 +1322,18 @@ where
|
|||
}
|
||||
|
||||
trait PyNumberIRShiftProtocolImpl {
|
||||
fn nb_inplace_rshift() -> Option<ffi::binaryfunc> {
|
||||
fn nb_inplace_rshift() -> Option<ffi::binaryfunc>;
|
||||
}
|
||||
|
||||
impl<'p, T> PyNumberIRShiftProtocolImpl for T
|
||||
where
|
||||
T: PyNumberProtocol<'p>,
|
||||
{
|
||||
default fn nb_inplace_rshift() -> Option<ffi::binaryfunc> {
|
||||
None
|
||||
}
|
||||
}
|
||||
|
||||
impl<'p, T> PyNumberIRShiftProtocolImpl for T where T: PyNumberProtocol<'p> {}
|
||||
|
||||
impl<T> PyNumberIRShiftProtocolImpl for T
|
||||
where
|
||||
T: for<'p> PyNumberIRShiftProtocol<'p>,
|
||||
|
@ -1221,13 +1344,18 @@ where
|
|||
}
|
||||
|
||||
trait PyNumberIAndProtocolImpl {
|
||||
fn nb_inplace_and() -> Option<ffi::binaryfunc> {
|
||||
fn nb_inplace_and() -> Option<ffi::binaryfunc>;
|
||||
}
|
||||
|
||||
impl<'p, T> PyNumberIAndProtocolImpl for T
|
||||
where
|
||||
T: PyNumberProtocol<'p>,
|
||||
{
|
||||
default fn nb_inplace_and() -> Option<ffi::binaryfunc> {
|
||||
None
|
||||
}
|
||||
}
|
||||
|
||||
impl<'p, T> PyNumberIAndProtocolImpl for T where T: PyNumberProtocol<'p> {}
|
||||
|
||||
impl<T> PyNumberIAndProtocolImpl for T
|
||||
where
|
||||
T: for<'p> PyNumberIAndProtocol<'p>,
|
||||
|
@ -1238,13 +1366,18 @@ where
|
|||
}
|
||||
|
||||
trait PyNumberIXorProtocolImpl {
|
||||
fn nb_inplace_xor() -> Option<ffi::binaryfunc> {
|
||||
fn nb_inplace_xor() -> Option<ffi::binaryfunc>;
|
||||
}
|
||||
|
||||
impl<'p, T> PyNumberIXorProtocolImpl for T
|
||||
where
|
||||
T: PyNumberProtocol<'p>,
|
||||
{
|
||||
default fn nb_inplace_xor() -> Option<ffi::binaryfunc> {
|
||||
None
|
||||
}
|
||||
}
|
||||
|
||||
impl<'p, T> PyNumberIXorProtocolImpl for T where T: PyNumberProtocol<'p> {}
|
||||
|
||||
impl<T> PyNumberIXorProtocolImpl for T
|
||||
where
|
||||
T: for<'p> PyNumberIXorProtocol<'p>,
|
||||
|
@ -1255,13 +1388,18 @@ where
|
|||
}
|
||||
|
||||
trait PyNumberIOrProtocolImpl {
|
||||
fn nb_inplace_or() -> Option<ffi::binaryfunc> {
|
||||
fn nb_inplace_or() -> Option<ffi::binaryfunc>;
|
||||
}
|
||||
|
||||
impl<'p, T> PyNumberIOrProtocolImpl for T
|
||||
where
|
||||
T: PyNumberProtocol<'p>,
|
||||
{
|
||||
default fn nb_inplace_or() -> Option<ffi::binaryfunc> {
|
||||
None
|
||||
}
|
||||
}
|
||||
|
||||
impl<'p, T> PyNumberIOrProtocolImpl for T where T: PyNumberProtocol<'p> {}
|
||||
|
||||
impl<T> PyNumberIOrProtocolImpl for T
|
||||
where
|
||||
T: for<'p> PyNumberIOrProtocol<'p>,
|
||||
|
@ -1273,13 +1411,18 @@ where
|
|||
|
||||
#[doc(hidden)]
|
||||
pub trait PyNumberRAddProtocolImpl {
|
||||
fn __radd__() -> Option<PyMethodDef> {
|
||||
fn __radd__() -> Option<PyMethodDef>;
|
||||
}
|
||||
|
||||
impl<'p, T> PyNumberRAddProtocolImpl for T
|
||||
where
|
||||
T: PyNumberProtocol<'p>,
|
||||
{
|
||||
default fn __radd__() -> Option<PyMethodDef> {
|
||||
None
|
||||
}
|
||||
}
|
||||
|
||||
impl<'p, T> PyNumberRAddProtocolImpl for T where T: PyNumberProtocol<'p> {}
|
||||
|
||||
#[doc(hidden)]
|
||||
pub trait PyNumberRSubProtocolImpl {
|
||||
fn __rsub__() -> Option<PyMethodDef> {
|
||||
|
@ -1291,120 +1434,185 @@ impl<'p, T> PyNumberRSubProtocolImpl for T where T: PyNumberProtocol<'p> {}
|
|||
|
||||
#[doc(hidden)]
|
||||
pub trait PyNumberRMulProtocolImpl {
|
||||
fn __rmul__() -> Option<PyMethodDef> {
|
||||
fn __rmul__() -> Option<PyMethodDef>;
|
||||
}
|
||||
|
||||
impl<'p, T> PyNumberRMulProtocolImpl for T
|
||||
where
|
||||
T: PyNumberProtocol<'p>,
|
||||
{
|
||||
default fn __rmul__() -> Option<PyMethodDef> {
|
||||
None
|
||||
}
|
||||
}
|
||||
|
||||
impl<'p, T> PyNumberRMulProtocolImpl for T where T: PyNumberProtocol<'p> {}
|
||||
|
||||
#[doc(hidden)]
|
||||
pub trait PyNumberRMatmulProtocolImpl {
|
||||
fn __rmatmul__() -> Option<PyMethodDef> {
|
||||
fn __rmatmul__() -> Option<PyMethodDef>;
|
||||
}
|
||||
|
||||
impl<'p, T> PyNumberRMatmulProtocolImpl for T
|
||||
where
|
||||
T: PyNumberProtocol<'p>,
|
||||
{
|
||||
default fn __rmatmul__() -> Option<PyMethodDef> {
|
||||
None
|
||||
}
|
||||
}
|
||||
|
||||
impl<'p, T> PyNumberRMatmulProtocolImpl for T where T: PyNumberProtocol<'p> {}
|
||||
|
||||
#[doc(hidden)]
|
||||
pub trait PyNumberRTruedivProtocolImpl {
|
||||
fn __rtruediv__() -> Option<PyMethodDef> {
|
||||
fn __rtruediv__() -> Option<PyMethodDef>;
|
||||
}
|
||||
|
||||
impl<'p, T> PyNumberRTruedivProtocolImpl for T
|
||||
where
|
||||
T: PyNumberProtocol<'p>,
|
||||
{
|
||||
default fn __rtruediv__() -> Option<PyMethodDef> {
|
||||
None
|
||||
}
|
||||
}
|
||||
|
||||
impl<'p, T> PyNumberRTruedivProtocolImpl for T where T: PyNumberProtocol<'p> {}
|
||||
|
||||
#[doc(hidden)]
|
||||
pub trait PyNumberRFloordivProtocolImpl {
|
||||
fn __rfloordiv__() -> Option<PyMethodDef> {
|
||||
fn __rfloordiv__() -> Option<PyMethodDef>;
|
||||
}
|
||||
|
||||
impl<'p, T> PyNumberRFloordivProtocolImpl for T
|
||||
where
|
||||
T: PyNumberProtocol<'p>,
|
||||
{
|
||||
default fn __rfloordiv__() -> Option<PyMethodDef> {
|
||||
None
|
||||
}
|
||||
}
|
||||
|
||||
impl<'p, T> PyNumberRFloordivProtocolImpl for T where T: PyNumberProtocol<'p> {}
|
||||
|
||||
#[doc(hidden)]
|
||||
pub trait PyNumberRModProtocolImpl {
|
||||
fn __rmod__() -> Option<PyMethodDef> {
|
||||
fn __rmod__() -> Option<PyMethodDef>;
|
||||
}
|
||||
|
||||
impl<'p, T> PyNumberRModProtocolImpl for T
|
||||
where
|
||||
T: PyNumberProtocol<'p>,
|
||||
{
|
||||
default fn __rmod__() -> Option<PyMethodDef> {
|
||||
None
|
||||
}
|
||||
}
|
||||
|
||||
impl<'p, T> PyNumberRModProtocolImpl for T where T: PyNumberProtocol<'p> {}
|
||||
|
||||
#[doc(hidden)]
|
||||
pub trait PyNumberRDivmodProtocolImpl {
|
||||
fn __rdivmod__() -> Option<PyMethodDef> {
|
||||
fn __rdivmod__() -> Option<PyMethodDef>;
|
||||
}
|
||||
|
||||
impl<'p, T> PyNumberRDivmodProtocolImpl for T
|
||||
where
|
||||
T: PyNumberProtocol<'p>,
|
||||
{
|
||||
default fn __rdivmod__() -> Option<PyMethodDef> {
|
||||
None
|
||||
}
|
||||
}
|
||||
|
||||
impl<'p, T> PyNumberRDivmodProtocolImpl for T where T: PyNumberProtocol<'p> {}
|
||||
|
||||
#[doc(hidden)]
|
||||
pub trait PyNumberRPowProtocolImpl {
|
||||
fn __rpow__() -> Option<PyMethodDef> {
|
||||
fn __rpow__() -> Option<PyMethodDef>;
|
||||
}
|
||||
|
||||
impl<'p, T> PyNumberRPowProtocolImpl for T
|
||||
where
|
||||
T: PyNumberProtocol<'p>,
|
||||
{
|
||||
default fn __rpow__() -> Option<PyMethodDef> {
|
||||
None
|
||||
}
|
||||
}
|
||||
|
||||
impl<'p, T> PyNumberRPowProtocolImpl for T where T: PyNumberProtocol<'p> {}
|
||||
|
||||
#[doc(hidden)]
|
||||
pub trait PyNumberRLShiftProtocolImpl {
|
||||
fn __rlshift__() -> Option<PyMethodDef> {
|
||||
fn __rlshift__() -> Option<PyMethodDef>;
|
||||
}
|
||||
|
||||
impl<'p, T> PyNumberRLShiftProtocolImpl for T
|
||||
where
|
||||
T: PyNumberProtocol<'p>,
|
||||
{
|
||||
default fn __rlshift__() -> Option<PyMethodDef> {
|
||||
None
|
||||
}
|
||||
}
|
||||
|
||||
impl<'p, T> PyNumberRLShiftProtocolImpl for T where T: PyNumberProtocol<'p> {}
|
||||
|
||||
#[doc(hidden)]
|
||||
pub trait PyNumberRRShiftProtocolImpl {
|
||||
fn __rrshift__() -> Option<PyMethodDef> {
|
||||
fn __rrshift__() -> Option<PyMethodDef>;
|
||||
}
|
||||
|
||||
impl<'p, T> PyNumberRRShiftProtocolImpl for T
|
||||
where
|
||||
T: PyNumberProtocol<'p>,
|
||||
{
|
||||
default fn __rrshift__() -> Option<PyMethodDef> {
|
||||
None
|
||||
}
|
||||
}
|
||||
|
||||
impl<'p, T> PyNumberRRShiftProtocolImpl for T where T: PyNumberProtocol<'p> {}
|
||||
|
||||
#[doc(hidden)]
|
||||
pub trait PyNumberRAndProtocolImpl {
|
||||
fn __rand__() -> Option<PyMethodDef> {
|
||||
fn __rand__() -> Option<PyMethodDef>;
|
||||
}
|
||||
|
||||
impl<'p, T> PyNumberRAndProtocolImpl for T
|
||||
where
|
||||
T: PyNumberProtocol<'p>,
|
||||
{
|
||||
default fn __rand__() -> Option<PyMethodDef> {
|
||||
None
|
||||
}
|
||||
}
|
||||
|
||||
impl<'p, T> PyNumberRAndProtocolImpl for T where T: PyNumberProtocol<'p> {}
|
||||
|
||||
#[doc(hidden)]
|
||||
pub trait PyNumberRXorProtocolImpl {
|
||||
fn __rxor__() -> Option<PyMethodDef> {
|
||||
fn __rxor__() -> Option<PyMethodDef>;
|
||||
}
|
||||
|
||||
impl<'p, T> PyNumberRXorProtocolImpl for T
|
||||
where
|
||||
T: PyNumberProtocol<'p>,
|
||||
{
|
||||
default fn __rxor__() -> Option<PyMethodDef> {
|
||||
None
|
||||
}
|
||||
}
|
||||
|
||||
impl<'p, T> PyNumberRXorProtocolImpl for T where T: PyNumberProtocol<'p> {}
|
||||
|
||||
#[doc(hidden)]
|
||||
pub trait PyNumberROrProtocolImpl {
|
||||
fn __ror__() -> Option<PyMethodDef> {
|
||||
fn __ror__() -> Option<PyMethodDef>;
|
||||
}
|
||||
|
||||
impl<'p, T> PyNumberROrProtocolImpl for T
|
||||
where
|
||||
T: PyNumberProtocol<'p>,
|
||||
{
|
||||
default fn __ror__() -> Option<PyMethodDef> {
|
||||
None
|
||||
}
|
||||
}
|
||||
|
||||
impl<'p, T> PyNumberROrProtocolImpl for T where T: PyNumberProtocol<'p> {}
|
||||
|
||||
trait PyNumberNegProtocolImpl {
|
||||
fn nb_negative() -> Option<ffi::unaryfunc> {
|
||||
fn nb_negative() -> Option<ffi::unaryfunc>;
|
||||
}
|
||||
|
||||
impl<'p, T> PyNumberNegProtocolImpl for T
|
||||
where
|
||||
T: PyNumberProtocol<'p>,
|
||||
{
|
||||
default fn nb_negative() -> Option<ffi::unaryfunc> {
|
||||
None
|
||||
}
|
||||
}
|
||||
|
||||
impl<'p, T> PyNumberNegProtocolImpl for T where T: PyNumberProtocol<'p> {}
|
||||
|
||||
impl<T> PyNumberNegProtocolImpl for T
|
||||
where
|
||||
T: for<'p> PyNumberNegProtocol<'p>,
|
||||
|
@ -1421,13 +1629,18 @@ where
|
|||
}
|
||||
|
||||
trait PyNumberPosProtocolImpl {
|
||||
fn nb_positive() -> Option<ffi::unaryfunc> {
|
||||
fn nb_positive() -> Option<ffi::unaryfunc>;
|
||||
}
|
||||
|
||||
impl<'p, T> PyNumberPosProtocolImpl for T
|
||||
where
|
||||
T: PyNumberProtocol<'p>,
|
||||
{
|
||||
default fn nb_positive() -> Option<ffi::unaryfunc> {
|
||||
None
|
||||
}
|
||||
}
|
||||
|
||||
impl<'p, T> PyNumberPosProtocolImpl for T where T: PyNumberProtocol<'p> {}
|
||||
|
||||
impl<T> PyNumberPosProtocolImpl for T
|
||||
where
|
||||
T: for<'p> PyNumberPosProtocol<'p>,
|
||||
|
@ -1443,13 +1656,18 @@ where
|
|||
}
|
||||
|
||||
trait PyNumberAbsProtocolImpl {
|
||||
fn nb_absolute() -> Option<ffi::unaryfunc> {
|
||||
fn nb_absolute() -> Option<ffi::unaryfunc>;
|
||||
}
|
||||
|
||||
impl<'p, T> PyNumberAbsProtocolImpl for T
|
||||
where
|
||||
T: PyNumberProtocol<'p>,
|
||||
{
|
||||
default fn nb_absolute() -> Option<ffi::unaryfunc> {
|
||||
None
|
||||
}
|
||||
}
|
||||
|
||||
impl<'p, T> PyNumberAbsProtocolImpl for T where T: PyNumberProtocol<'p> {}
|
||||
|
||||
impl<T> PyNumberAbsProtocolImpl for T
|
||||
where
|
||||
T: for<'p> PyNumberAbsProtocol<'p>,
|
||||
|
@ -1465,13 +1683,18 @@ where
|
|||
}
|
||||
|
||||
trait PyNumberInvertProtocolImpl {
|
||||
fn nb_invert() -> Option<ffi::unaryfunc> {
|
||||
fn nb_invert() -> Option<ffi::unaryfunc>;
|
||||
}
|
||||
|
||||
impl<'p, T> PyNumberInvertProtocolImpl for T
|
||||
where
|
||||
T: PyNumberProtocol<'p>,
|
||||
{
|
||||
default fn nb_invert() -> Option<ffi::unaryfunc> {
|
||||
None
|
||||
}
|
||||
}
|
||||
|
||||
impl<'p, T> PyNumberInvertProtocolImpl for T where T: PyNumberProtocol<'p> {}
|
||||
|
||||
impl<T> PyNumberInvertProtocolImpl for T
|
||||
where
|
||||
T: for<'p> PyNumberInvertProtocol<'p>,
|
||||
|
@ -1487,13 +1710,18 @@ where
|
|||
}
|
||||
|
||||
trait PyNumberIntProtocolImpl {
|
||||
fn nb_int() -> Option<ffi::unaryfunc> {
|
||||
fn nb_int() -> Option<ffi::unaryfunc>;
|
||||
}
|
||||
|
||||
impl<'p, T> PyNumberIntProtocolImpl for T
|
||||
where
|
||||
T: PyNumberProtocol<'p>,
|
||||
{
|
||||
default fn nb_int() -> Option<ffi::unaryfunc> {
|
||||
None
|
||||
}
|
||||
}
|
||||
|
||||
impl<'p, T> PyNumberIntProtocolImpl for T where T: PyNumberProtocol<'p> {}
|
||||
|
||||
impl<T> PyNumberIntProtocolImpl for T
|
||||
where
|
||||
T: for<'p> PyNumberIntProtocol<'p>,
|
||||
|
@ -1509,13 +1737,18 @@ where
|
|||
}
|
||||
|
||||
trait PyNumberFloatProtocolImpl {
|
||||
fn nb_float() -> Option<ffi::unaryfunc> {
|
||||
fn nb_float() -> Option<ffi::unaryfunc>;
|
||||
}
|
||||
|
||||
impl<'p, T> PyNumberFloatProtocolImpl for T
|
||||
where
|
||||
T: PyNumberProtocol<'p>,
|
||||
{
|
||||
default fn nb_float() -> Option<ffi::unaryfunc> {
|
||||
None
|
||||
}
|
||||
}
|
||||
|
||||
impl<'p, T> PyNumberFloatProtocolImpl for T where T: PyNumberProtocol<'p> {}
|
||||
|
||||
impl<T> PyNumberFloatProtocolImpl for T
|
||||
where
|
||||
T: for<'p> PyNumberFloatProtocol<'p>,
|
||||
|
@ -1531,13 +1764,18 @@ where
|
|||
}
|
||||
|
||||
trait PyNumberIndexProtocolImpl {
|
||||
fn nb_index() -> Option<ffi::unaryfunc> {
|
||||
fn nb_index() -> Option<ffi::unaryfunc>;
|
||||
}
|
||||
|
||||
impl<'p, T> PyNumberIndexProtocolImpl for T
|
||||
where
|
||||
T: PyNumberProtocol<'p>,
|
||||
{
|
||||
default fn nb_index() -> Option<ffi::unaryfunc> {
|
||||
None
|
||||
}
|
||||
}
|
||||
|
||||
impl<'p, T> PyNumberIndexProtocolImpl for T where T: PyNumberProtocol<'p> {}
|
||||
|
||||
impl<T> PyNumberIndexProtocolImpl for T
|
||||
where
|
||||
T: for<'p> PyNumberIndexProtocol<'p>,
|
||||
|
@ -1553,17 +1791,27 @@ where
|
|||
}
|
||||
|
||||
trait PyNumberComplexProtocolImpl {
|
||||
fn __complex__() -> Option<PyMethodDef> {
|
||||
fn __complex__() -> Option<PyMethodDef>;
|
||||
}
|
||||
|
||||
impl<'p, T> PyNumberComplexProtocolImpl for T
|
||||
where
|
||||
T: PyNumberProtocol<'p>,
|
||||
{
|
||||
default fn __complex__() -> Option<PyMethodDef> {
|
||||
None
|
||||
}
|
||||
}
|
||||
|
||||
impl<'p, T> PyNumberComplexProtocolImpl for T where T: PyNumberProtocol<'p> {}
|
||||
|
||||
trait PyNumberRoundProtocolImpl {
|
||||
fn __round__() -> Option<PyMethodDef> {
|
||||
fn __round__() -> Option<PyMethodDef>;
|
||||
}
|
||||
|
||||
impl<'p, T> PyNumberRoundProtocolImpl for T
|
||||
where
|
||||
T: PyNumberProtocol<'p>,
|
||||
{
|
||||
default fn __round__() -> Option<PyMethodDef> {
|
||||
None
|
||||
}
|
||||
}
|
||||
|
||||
impl<'p, T> PyNumberRoundProtocolImpl for T where T: PyNumberProtocol<'p> {}
|
||||
|
|
|
@ -91,17 +91,20 @@ pub trait PyAsyncAexitProtocol<'p>: PyAsyncProtocol<'p> {
|
|||
|
||||
#[doc(hidden)]
|
||||
pub trait PyAsyncProtocolImpl {
|
||||
fn tp_as_async() -> Option<ffi::PyAsyncMethods> {
|
||||
fn tp_as_async() -> Option<ffi::PyAsyncMethods>;
|
||||
fn methods() -> Vec<PyMethodDef>;
|
||||
}
|
||||
|
||||
impl<T> PyAsyncProtocolImpl for T {
|
||||
default fn tp_as_async() -> Option<ffi::PyAsyncMethods> {
|
||||
None
|
||||
}
|
||||
|
||||
fn methods() -> Vec<PyMethodDef> {
|
||||
default fn methods() -> Vec<PyMethodDef> {
|
||||
Vec::new()
|
||||
}
|
||||
}
|
||||
|
||||
impl<T> PyAsyncProtocolImpl for T {}
|
||||
|
||||
impl<'p, T> PyAsyncProtocolImpl for T
|
||||
where
|
||||
T: PyAsyncProtocol<'p>,
|
||||
|
@ -131,13 +134,18 @@ where
|
|||
}
|
||||
|
||||
trait PyAsyncAwaitProtocolImpl {
|
||||
fn am_await() -> Option<ffi::unaryfunc> {
|
||||
fn am_await() -> Option<ffi::unaryfunc>;
|
||||
}
|
||||
|
||||
impl<'p, T> PyAsyncAwaitProtocolImpl for T
|
||||
where
|
||||
T: PyAsyncProtocol<'p>,
|
||||
{
|
||||
default fn am_await() -> Option<ffi::unaryfunc> {
|
||||
None
|
||||
}
|
||||
}
|
||||
|
||||
impl<'p, T> PyAsyncAwaitProtocolImpl for T where T: PyAsyncProtocol<'p> {}
|
||||
|
||||
impl<T> PyAsyncAwaitProtocolImpl for T
|
||||
where
|
||||
T: for<'p> PyAsyncAwaitProtocol<'p>,
|
||||
|
@ -154,13 +162,18 @@ where
|
|||
}
|
||||
|
||||
trait PyAsyncAiterProtocolImpl {
|
||||
fn am_aiter() -> Option<ffi::unaryfunc> {
|
||||
fn am_aiter() -> Option<ffi::unaryfunc>;
|
||||
}
|
||||
|
||||
impl<'p, T> PyAsyncAiterProtocolImpl for T
|
||||
where
|
||||
T: PyAsyncProtocol<'p>,
|
||||
{
|
||||
default fn am_aiter() -> Option<ffi::unaryfunc> {
|
||||
None
|
||||
}
|
||||
}
|
||||
|
||||
impl<'p, T> PyAsyncAiterProtocolImpl for T where T: PyAsyncProtocol<'p> {}
|
||||
|
||||
impl<T> PyAsyncAiterProtocolImpl for T
|
||||
where
|
||||
T: for<'p> PyAsyncAiterProtocol<'p>,
|
||||
|
@ -177,13 +190,18 @@ where
|
|||
}
|
||||
|
||||
trait PyAsyncAnextProtocolImpl {
|
||||
fn am_anext() -> Option<ffi::unaryfunc> {
|
||||
fn am_anext() -> Option<ffi::unaryfunc>;
|
||||
}
|
||||
|
||||
impl<'p, T> PyAsyncAnextProtocolImpl for T
|
||||
where
|
||||
T: PyAsyncProtocol<'p>,
|
||||
{
|
||||
default fn am_anext() -> Option<ffi::unaryfunc> {
|
||||
None
|
||||
}
|
||||
}
|
||||
|
||||
impl<'p, T> PyAsyncAnextProtocolImpl for T where T: PyAsyncProtocol<'p> {}
|
||||
|
||||
mod anext {
|
||||
use super::{PyAsyncAnextProtocol, PyAsyncAnextProtocolImpl};
|
||||
use crate::callback::CallbackConverter;
|
||||
|
@ -233,17 +251,27 @@ mod anext {
|
|||
}
|
||||
|
||||
trait PyAsyncAenterProtocolImpl {
|
||||
fn __aenter__() -> Option<PyMethodDef> {
|
||||
fn __aenter__() -> Option<PyMethodDef>;
|
||||
}
|
||||
|
||||
impl<'p, T> PyAsyncAenterProtocolImpl for T
|
||||
where
|
||||
T: PyAsyncProtocol<'p>,
|
||||
{
|
||||
default fn __aenter__() -> Option<PyMethodDef> {
|
||||
None
|
||||
}
|
||||
}
|
||||
|
||||
impl<'p, T> PyAsyncAenterProtocolImpl for T where T: PyAsyncProtocol<'p> {}
|
||||
|
||||
trait PyAsyncAexitProtocolImpl {
|
||||
fn __aexit__() -> Option<PyMethodDef> {
|
||||
fn __aexit__() -> Option<PyMethodDef>;
|
||||
}
|
||||
|
||||
impl<'p, T> PyAsyncAexitProtocolImpl for T
|
||||
where
|
||||
T: PyAsyncProtocol<'p>,
|
||||
{
|
||||
default fn __aexit__() -> Option<PyMethodDef> {
|
||||
None
|
||||
}
|
||||
}
|
||||
|
||||
impl<'p, T> PyAsyncAexitProtocolImpl for T where T: PyAsyncProtocol<'p> {}
|
||||
|
|
|
@ -134,13 +134,15 @@ pub trait PySequenceInplaceRepeatProtocol<'p>: PySequenceProtocol<'p> + IntoPy<P
|
|||
|
||||
#[doc(hidden)]
|
||||
pub trait PySequenceProtocolImpl {
|
||||
fn tp_as_sequence() -> Option<ffi::PySequenceMethods> {
|
||||
fn tp_as_sequence() -> Option<ffi::PySequenceMethods>;
|
||||
}
|
||||
|
||||
impl<T> PySequenceProtocolImpl for T {
|
||||
default fn tp_as_sequence() -> Option<ffi::PySequenceMethods> {
|
||||
None
|
||||
}
|
||||
}
|
||||
|
||||
impl<T> PySequenceProtocolImpl for T {}
|
||||
|
||||
impl<'p, T> PySequenceProtocolImpl for T
|
||||
where
|
||||
T: PySequenceProtocol<'p>,
|
||||
|
@ -162,13 +164,18 @@ where
|
|||
}
|
||||
|
||||
trait PySequenceLenProtocolImpl {
|
||||
fn sq_length() -> Option<ffi::lenfunc> {
|
||||
fn sq_length() -> Option<ffi::lenfunc>;
|
||||
}
|
||||
|
||||
impl<'p, T> PySequenceLenProtocolImpl for T
|
||||
where
|
||||
T: PySequenceProtocol<'p>,
|
||||
{
|
||||
default fn sq_length() -> Option<ffi::lenfunc> {
|
||||
None
|
||||
}
|
||||
}
|
||||
|
||||
impl<'p, T> PySequenceLenProtocolImpl for T where T: PySequenceProtocol<'p> {}
|
||||
|
||||
impl<T> PySequenceLenProtocolImpl for T
|
||||
where
|
||||
T: for<'p> PySequenceLenProtocol<'p>,
|
||||
|
@ -179,13 +186,18 @@ where
|
|||
}
|
||||
|
||||
trait PySequenceGetItemProtocolImpl {
|
||||
fn sq_item() -> Option<ffi::ssizeargfunc> {
|
||||
fn sq_item() -> Option<ffi::ssizeargfunc>;
|
||||
}
|
||||
|
||||
impl<'p, T> PySequenceGetItemProtocolImpl for T
|
||||
where
|
||||
T: PySequenceProtocol<'p>,
|
||||
{
|
||||
default fn sq_item() -> Option<ffi::ssizeargfunc> {
|
||||
None
|
||||
}
|
||||
}
|
||||
|
||||
impl<'p, T> PySequenceGetItemProtocolImpl for T where T: PySequenceProtocol<'p> {}
|
||||
|
||||
impl<T> PySequenceGetItemProtocolImpl for T
|
||||
where
|
||||
T: for<'p> PySequenceGetItemProtocol<'p>,
|
||||
|
@ -201,13 +213,18 @@ where
|
|||
}
|
||||
|
||||
trait PySequenceSetItemProtocolImpl {
|
||||
fn sq_ass_item() -> Option<ffi::ssizeobjargproc> {
|
||||
fn sq_ass_item() -> Option<ffi::ssizeobjargproc>;
|
||||
}
|
||||
|
||||
impl<'p, T> PySequenceSetItemProtocolImpl for T
|
||||
where
|
||||
T: PySequenceProtocol<'p>,
|
||||
{
|
||||
default fn sq_ass_item() -> Option<ffi::ssizeobjargproc> {
|
||||
None
|
||||
}
|
||||
}
|
||||
|
||||
impl<'p, T> PySequenceSetItemProtocolImpl for T where T: PySequenceProtocol<'p> {}
|
||||
|
||||
impl<T> PySequenceSetItemProtocolImpl for T
|
||||
where
|
||||
T: for<'p> PySequenceSetItemProtocol<'p>,
|
||||
|
@ -275,13 +292,18 @@ mod sq_ass_item_impl {
|
|||
}
|
||||
|
||||
trait DelItem {
|
||||
fn del_item() -> Option<ffi::ssizeobjargproc> {
|
||||
fn del_item() -> Option<ffi::ssizeobjargproc>;
|
||||
}
|
||||
|
||||
impl<'p, T> DelItem for T
|
||||
where
|
||||
T: PySequenceProtocol<'p>,
|
||||
{
|
||||
default fn del_item() -> Option<ffi::ssizeobjargproc> {
|
||||
None
|
||||
}
|
||||
}
|
||||
|
||||
impl<'p, T> DelItem for T where T: PySequenceProtocol<'p> {}
|
||||
|
||||
impl<T> DelItem for T
|
||||
where
|
||||
T: for<'p> PySequenceDelItemProtocol<'p>,
|
||||
|
@ -321,13 +343,18 @@ mod sq_ass_item_impl {
|
|||
}
|
||||
|
||||
trait DelSetItem {
|
||||
fn del_set_item() -> Option<ffi::ssizeobjargproc> {
|
||||
fn del_set_item() -> Option<ffi::ssizeobjargproc>;
|
||||
}
|
||||
|
||||
impl<'p, T> DelSetItem for T
|
||||
where
|
||||
T: PySequenceProtocol<'p>,
|
||||
{
|
||||
default fn del_set_item() -> Option<ffi::ssizeobjargproc> {
|
||||
None
|
||||
}
|
||||
}
|
||||
|
||||
impl<'p, T> DelSetItem for T where T: PySequenceProtocol<'p> {}
|
||||
|
||||
impl<T> DelSetItem for T
|
||||
where
|
||||
T: for<'p> PySequenceSetItemProtocol<'p> + for<'p> PySequenceDelItemProtocol<'p>,
|
||||
|
@ -368,13 +395,18 @@ mod sq_ass_item_impl {
|
|||
}
|
||||
|
||||
trait PySequenceContainsProtocolImpl {
|
||||
fn sq_contains() -> Option<ffi::objobjproc> {
|
||||
fn sq_contains() -> Option<ffi::objobjproc>;
|
||||
}
|
||||
|
||||
impl<'p, T> PySequenceContainsProtocolImpl for T
|
||||
where
|
||||
T: PySequenceProtocol<'p>,
|
||||
{
|
||||
default fn sq_contains() -> Option<ffi::objobjproc> {
|
||||
None
|
||||
}
|
||||
}
|
||||
|
||||
impl<'p, T> PySequenceContainsProtocolImpl for T where T: PySequenceProtocol<'p> {}
|
||||
|
||||
impl<T> PySequenceContainsProtocolImpl for T
|
||||
where
|
||||
T: for<'p> PySequenceContainsProtocol<'p>,
|
||||
|
@ -391,13 +423,18 @@ where
|
|||
}
|
||||
|
||||
trait PySequenceConcatProtocolImpl {
|
||||
fn sq_concat() -> Option<ffi::binaryfunc> {
|
||||
fn sq_concat() -> Option<ffi::binaryfunc>;
|
||||
}
|
||||
|
||||
impl<'p, T> PySequenceConcatProtocolImpl for T
|
||||
where
|
||||
T: PySequenceProtocol<'p>,
|
||||
{
|
||||
default fn sq_concat() -> Option<ffi::binaryfunc> {
|
||||
None
|
||||
}
|
||||
}
|
||||
|
||||
impl<'p, T> PySequenceConcatProtocolImpl for T where T: PySequenceProtocol<'p> {}
|
||||
|
||||
impl<T> PySequenceConcatProtocolImpl for T
|
||||
where
|
||||
T: for<'p> PySequenceConcatProtocol<'p>,
|
||||
|
@ -413,13 +450,18 @@ where
|
|||
}
|
||||
|
||||
trait PySequenceRepeatProtocolImpl {
|
||||
fn sq_repeat() -> Option<ffi::ssizeargfunc> {
|
||||
fn sq_repeat() -> Option<ffi::ssizeargfunc>;
|
||||
}
|
||||
|
||||
impl<'p, T> PySequenceRepeatProtocolImpl for T
|
||||
where
|
||||
T: PySequenceProtocol<'p>,
|
||||
{
|
||||
default fn sq_repeat() -> Option<ffi::ssizeargfunc> {
|
||||
None
|
||||
}
|
||||
}
|
||||
|
||||
impl<'p, T> PySequenceRepeatProtocolImpl for T where T: PySequenceProtocol<'p> {}
|
||||
|
||||
impl<T> PySequenceRepeatProtocolImpl for T
|
||||
where
|
||||
T: for<'p> PySequenceRepeatProtocol<'p>,
|
||||
|
@ -435,13 +477,18 @@ where
|
|||
}
|
||||
|
||||
trait PySequenceInplaceConcatProtocolImpl {
|
||||
fn sq_inplace_concat() -> Option<ffi::binaryfunc> {
|
||||
fn sq_inplace_concat() -> Option<ffi::binaryfunc>;
|
||||
}
|
||||
|
||||
impl<'p, T> PySequenceInplaceConcatProtocolImpl for T
|
||||
where
|
||||
T: PySequenceProtocol<'p>,
|
||||
{
|
||||
default fn sq_inplace_concat() -> Option<ffi::binaryfunc> {
|
||||
None
|
||||
}
|
||||
}
|
||||
|
||||
impl<'p, T> PySequenceInplaceConcatProtocolImpl for T where T: PySequenceProtocol<'p> {}
|
||||
|
||||
impl<T> PySequenceInplaceConcatProtocolImpl for T
|
||||
where
|
||||
T: for<'p> PySequenceInplaceConcatProtocol<'p>,
|
||||
|
@ -457,13 +504,18 @@ where
|
|||
}
|
||||
|
||||
trait PySequenceInplaceRepeatProtocolImpl {
|
||||
fn sq_inplace_repeat() -> Option<ffi::ssizeargfunc> {
|
||||
fn sq_inplace_repeat() -> Option<ffi::ssizeargfunc>;
|
||||
}
|
||||
|
||||
impl<'p, T> PySequenceInplaceRepeatProtocolImpl for T
|
||||
where
|
||||
T: PySequenceProtocol<'p>,
|
||||
{
|
||||
default fn sq_inplace_repeat() -> Option<ffi::ssizeargfunc> {
|
||||
None
|
||||
}
|
||||
}
|
||||
|
||||
impl<'p, T> PySequenceInplaceRepeatProtocolImpl for T where T: PySequenceProtocol<'p> {}
|
||||
|
||||
impl<T> PySequenceInplaceRepeatProtocolImpl for T
|
||||
where
|
||||
T: for<'p> PySequenceInplaceRepeatProtocol<'p>,
|
||||
|
|
|
@ -96,6 +96,15 @@ pub trait ToBorrowedObject: ToPyObject {
|
|||
/// May be more efficient than `to_object` because it does not need
|
||||
/// to touch any reference counts when the input object already is a Python object.
|
||||
fn with_borrowed_ptr<F, R>(&self, py: Python, f: F) -> R
|
||||
where
|
||||
F: FnOnce(*mut ffi::PyObject) -> R;
|
||||
}
|
||||
|
||||
impl<T> ToBorrowedObject for T
|
||||
where
|
||||
T: ToPyObject,
|
||||
{
|
||||
default fn with_borrowed_ptr<F, R>(&self, py: Python, f: F) -> R
|
||||
where
|
||||
F: FnOnce(*mut ffi::PyObject) -> R,
|
||||
{
|
||||
|
@ -108,8 +117,6 @@ pub trait ToBorrowedObject: ToPyObject {
|
|||
}
|
||||
}
|
||||
|
||||
impl<T> ToBorrowedObject for T where T: ToPyObject {}
|
||||
|
||||
impl<T> ToBorrowedObject for T
|
||||
where
|
||||
T: ToPyObject + AsPyPointer,
|
||||
|
|
|
@ -359,13 +359,18 @@ impl<T> Py<T> {
|
|||
|
||||
/// Specialization workaround
|
||||
trait AsPyRefDispatch<T: PyTypeInfo>: AsPyPointer {
|
||||
fn as_ref_dispatch(&self, _py: Python) -> &T {
|
||||
fn as_ref_dispatch(&self, _py: Python) -> &T;
|
||||
fn as_mut_dispatch(&mut self, _py: Python) -> &mut T;
|
||||
}
|
||||
|
||||
impl<T: PyTypeInfo> AsPyRefDispatch<T> for Py<T> {
|
||||
default fn as_ref_dispatch(&self, _py: Python) -> &T {
|
||||
unsafe {
|
||||
let ptr = (self.as_ptr() as *mut u8).offset(T::OFFSET) as *mut T;
|
||||
ptr.as_ref().expect("Py has a null pointer")
|
||||
}
|
||||
}
|
||||
fn as_mut_dispatch(&mut self, _py: Python) -> &mut T {
|
||||
default fn as_mut_dispatch(&mut self, _py: Python) -> &mut T {
|
||||
unsafe {
|
||||
let ptr = (self.as_ptr() as *mut u8).offset(T::OFFSET) as *mut T;
|
||||
ptr.as_mut().expect("Py has a null pointer")
|
||||
|
@ -373,8 +378,6 @@ trait AsPyRefDispatch<T: PyTypeInfo>: AsPyPointer {
|
|||
}
|
||||
}
|
||||
|
||||
impl<T: PyTypeInfo> AsPyRefDispatch<T> for Py<T> {}
|
||||
|
||||
impl<T: PyTypeInfo + PyNativeType> AsPyRefDispatch<T> for Py<T> {
|
||||
fn as_ref_dispatch(&self, _py: Python) -> &T {
|
||||
unsafe { &*(self as *const instance::Py<T> as *const T) }
|
||||
|
@ -553,22 +556,10 @@ impl<'p, T: ToPyObject> AsPyPointer for ManagedPyRef<'p, T> {
|
|||
/// Helper trait to choose the right implementation for [ManagedPyRef]
|
||||
pub trait ManagedPyRefDispatch: ToPyObject {
|
||||
/// Optionally converts into a python object and stores the pointer to the python heap.
|
||||
///
|
||||
/// Contains the case 1 impl (with to_object) to avoid a specialization error
|
||||
fn to_managed_py_ref<'p>(&self, py: Python<'p>) -> ManagedPyRef<'p, Self> {
|
||||
ManagedPyRef {
|
||||
data: self.to_object(py).into_ptr(),
|
||||
data_type: PhantomData,
|
||||
_py: py,
|
||||
}
|
||||
}
|
||||
fn to_managed_py_ref<'p>(&self, py: Python<'p>) -> ManagedPyRef<'p, Self>;
|
||||
|
||||
/// Dispatch over a xdecref and a noop drop impl
|
||||
///
|
||||
/// Contains the case 1 impl (decref) to avoid a specialization error
|
||||
fn drop_impl(borrowed: &mut ManagedPyRef<Self>) {
|
||||
unsafe { ffi::Py_DECREF(borrowed.data) };
|
||||
}
|
||||
fn drop_impl(borrowed: &mut ManagedPyRef<Self>);
|
||||
}
|
||||
|
||||
/// Case 1: It's a rust object which still needs to be converted to a python object.
|
||||
|
@ -577,7 +568,21 @@ pub trait ManagedPyRefDispatch: ToPyObject {
|
|||
///
|
||||
/// Note that the actual implementations are part of the trait declaration to avoid
|
||||
/// a specialization error
|
||||
impl<T: ToPyObject + ?Sized> ManagedPyRefDispatch for T {}
|
||||
impl<T: ToPyObject + ?Sized> ManagedPyRefDispatch for T {
|
||||
/// Contains the case 1 impl (with to_object) to avoid a specialization error
|
||||
default fn to_managed_py_ref<'p>(&self, py: Python<'p>) -> ManagedPyRef<'p, Self> {
|
||||
ManagedPyRef {
|
||||
data: self.to_object(py).into_ptr(),
|
||||
data_type: PhantomData,
|
||||
_py: py,
|
||||
}
|
||||
}
|
||||
|
||||
/// Contains the case 1 impl (decref) to avoid a specialization error
|
||||
default fn drop_impl(borrowed: &mut ManagedPyRef<Self>) {
|
||||
unsafe { ffi::Py_DECREF(borrowed.data) };
|
||||
}
|
||||
}
|
||||
|
||||
/// Case 2: It's an object on the python heap, we're just storing a borrowed pointer.
|
||||
/// The object we're getting is an owned pointer, it might have it's own drop impl.
|
||||
|
|
Loading…
Reference in a new issue