From 5397a62f486a25b2f99aac7aa758161b993af6ae Mon Sep 17 00:00:00 2001 From: Martin Larralde Date: Mon, 7 Oct 2019 16:01:09 +0200 Subject: [PATCH 1/2] Fix broken specialized implementations with Rust 1.40 --- src/class/basic.rs | 94 ++++++---- src/class/buffer.rs | 16 +- src/class/context.rs | 24 ++- src/class/descr.rs | 25 ++- src/class/gc.rs | 22 ++- src/class/iter.rs | 22 ++- src/class/mapping.rs | 75 +++++--- src/class/number.rs | 403 ++++++++++++++++++++++++++---------------- src/class/pyasync.rs | 51 ++++-- src/class/sequence.rs | 88 +++++---- src/conversion.rs | 8 +- src/instance.rs | 43 +++-- 12 files changed, 546 insertions(+), 325 deletions(-) diff --git a/src/class/basic.rs b/src/class/basic.rs index c3153dfa..29e19871 100644 --- a/src/class/basic.rs +++ b/src/class/basic.rs @@ -152,17 +152,21 @@ pub trait PyObjectRichcmpProtocol<'p>: PyObjectProtocol<'p> { #[doc(hidden)] pub trait PyObjectProtocolImpl { - fn methods() -> Vec { + fn methods() -> Vec; + fn tp_as_object(_type_object: &mut ffi::PyTypeObject); + fn nb_bool_fn() -> Option; +} + +impl PyObjectProtocolImpl for T { + default fn methods() -> Vec { Vec::new() } - fn tp_as_object(_type_object: &mut ffi::PyTypeObject) {} - fn nb_bool_fn() -> Option { + default fn tp_as_object(_type_object: &mut ffi::PyTypeObject) {} + default fn nb_bool_fn() -> Option { None } } -impl PyObjectProtocolImpl for T {} - impl<'p, T> PyObjectProtocolImpl for T where T: PyObjectProtocol<'p>, @@ -195,13 +199,15 @@ where } trait GetAttrProtocolImpl { - fn tp_getattro() -> Option { + fn tp_getattro() -> Option; +} + +impl<'p, T> GetAttrProtocolImpl for T where T: PyObjectProtocol<'p> { + default fn tp_getattro() -> Option { None } } -impl<'p, T> GetAttrProtocolImpl for T where T: PyObjectProtocol<'p> {} - impl GetAttrProtocolImpl for T where T: for<'p> PyObjectGetAttrProtocol<'p>, @@ -268,13 +274,15 @@ mod tp_setattro_impl { } trait SetAttr { - fn set_attr() -> Option { + fn set_attr() -> Option; + } + + impl<'p, T: PyObjectProtocol<'p>> SetAttr for T { + default fn set_attr() -> Option { None } } - impl<'p, T: PyObjectProtocol<'p>> SetAttr for T {} - impl SetAttr for T where T: for<'p> PyObjectSetAttrProtocol<'p>, @@ -285,13 +293,15 @@ mod tp_setattro_impl { } trait DelAttr { - fn del_attr() -> Option { + fn del_attr() -> Option; + } + + impl<'p, T> DelAttr for T where T: PyObjectProtocol<'p> { + default fn del_attr() -> Option { None } } - impl<'p, T> DelAttr for T where T: PyObjectProtocol<'p> {} - impl DelAttr for T where T: for<'p> PyObjectDelAttrProtocol<'p>, @@ -302,13 +312,15 @@ mod tp_setattro_impl { } trait SetDelAttr { - fn set_del_attr() -> Option { + fn set_del_attr() -> Option; + } + + impl<'p, T> SetDelAttr for T where T: PyObjectProtocol<'p> { + default fn set_del_attr() -> Option { None } } - impl<'p, T> SetDelAttr for T where T: PyObjectProtocol<'p> {} - impl SetDelAttr for T where T: for<'p> PyObjectSetAttrProtocol<'p> + for<'p> PyObjectDelAttrProtocol<'p>, @@ -326,11 +338,13 @@ mod tp_setattro_impl { } trait StrProtocolImpl { - fn tp_str() -> Option { + fn tp_str() -> Option; +} +impl<'p, T> StrProtocolImpl for T where T: PyObjectProtocol<'p> { + default fn tp_str() -> Option { None } } -impl<'p, T> StrProtocolImpl for T where T: PyObjectProtocol<'p> {} impl StrProtocolImpl for T where T: for<'p> PyObjectStrProtocol<'p>, @@ -346,11 +360,13 @@ where } trait ReprProtocolImpl { - fn tp_repr() -> Option { + fn tp_repr() -> Option; +} +impl<'p, T> ReprProtocolImpl for T where T: PyObjectProtocol<'p> { + default fn tp_repr() -> Option { None } } -impl<'p, T> ReprProtocolImpl for T where T: PyObjectProtocol<'p> {} impl ReprProtocolImpl for T where T: for<'p> PyObjectReprProtocol<'p>, @@ -367,34 +383,42 @@ where #[doc(hidden)] pub trait FormatProtocolImpl { - fn __format__() -> Option { + fn __format__() -> Option; +} +impl<'p, T> FormatProtocolImpl for T where T: PyObjectProtocol<'p> { + default fn __format__() -> Option { None } } -impl<'p, T> FormatProtocolImpl for T where T: PyObjectProtocol<'p> {} #[doc(hidden)] pub trait BytesProtocolImpl { - fn __bytes__() -> Option { + fn __bytes__() -> Option; +} +impl<'p, T> BytesProtocolImpl for T where T: PyObjectProtocol<'p> { + default fn __bytes__() -> Option { None } } -impl<'p, T> BytesProtocolImpl for T where T: PyObjectProtocol<'p> {} #[doc(hidden)] pub trait UnicodeProtocolImpl { - fn __unicode__() -> Option { + fn __unicode__() -> Option; +} +impl<'p, T> UnicodeProtocolImpl for T where T: PyObjectProtocol<'p> { + default fn __unicode__() -> Option { None } } -impl<'p, T> UnicodeProtocolImpl for T where T: PyObjectProtocol<'p> {} trait HashProtocolImpl { - fn tp_hash() -> Option { + fn tp_hash() -> Option; +} +impl<'p, T> HashProtocolImpl for T where T: PyObjectProtocol<'p> { + default fn tp_hash() -> Option { None } } -impl<'p, T> HashProtocolImpl for T where T: PyObjectProtocol<'p> {} impl HashProtocolImpl for T where T: for<'p> PyObjectHashProtocol<'p>, @@ -411,11 +435,13 @@ where } trait BoolProtocolImpl { - fn nb_bool() -> Option { + fn nb_bool() -> Option; +} +impl<'p, T> BoolProtocolImpl for T where T: PyObjectProtocol<'p> { + default fn nb_bool() -> Option { None } } -impl<'p, T> BoolProtocolImpl for T where T: PyObjectProtocol<'p> {} impl BoolProtocolImpl for T where T: for<'p> PyObjectBoolProtocol<'p>, @@ -432,11 +458,13 @@ where } trait RichcmpProtocolImpl { - fn tp_richcompare() -> Option { + fn tp_richcompare() -> Option; +} +impl<'p, T> RichcmpProtocolImpl for T where T: PyObjectProtocol<'p> { + default fn tp_richcompare() -> Option { None } } -impl<'p, T> RichcmpProtocolImpl for T where T: PyObjectProtocol<'p> {} impl RichcmpProtocolImpl for T where T: for<'p> PyObjectRichcmpProtocol<'p>, diff --git a/src/class/buffer.rs b/src/class/buffer.rs index d36524e7..c30f078c 100644 --- a/src/class/buffer.rs +++ b/src/class/buffer.rs @@ -41,13 +41,15 @@ pub trait PyBufferReleaseBufferProtocol<'p>: PyBufferProtocol<'p> { #[doc(hidden)] pub trait PyBufferProtocolImpl { - fn tp_as_buffer() -> Option { + fn tp_as_buffer() -> Option; +} + +impl PyBufferProtocolImpl for T { + default fn tp_as_buffer() -> Option { None } } -impl PyBufferProtocolImpl for T {} - impl<'p, T> PyBufferProtocolImpl for T where T: PyBufferProtocol<'p>, @@ -64,13 +66,15 @@ where } trait PyBufferGetBufferProtocolImpl { - fn cb_bf_getbuffer() -> Option { + fn cb_bf_getbuffer() -> Option; +} + +impl<'p, T> PyBufferGetBufferProtocolImpl for T where T: PyBufferProtocol<'p> { + default fn cb_bf_getbuffer() -> Option { None } } -impl<'p, T> PyBufferGetBufferProtocolImpl for T where T: PyBufferProtocol<'p> {} - impl PyBufferGetBufferProtocolImpl for T where T: for<'p> PyBufferGetBufferProtocol<'p>, diff --git a/src/class/context.rs b/src/class/context.rs index 092527ba..2ad59768 100644 --- a/src/class/context.rs +++ b/src/class/context.rs @@ -47,13 +47,15 @@ pub trait PyContextExitProtocol<'p>: PyContextProtocol<'p> { #[doc(hidden)] pub trait PyContextProtocolImpl { - fn methods() -> Vec { + fn methods() -> Vec; +} + +impl PyContextProtocolImpl for T { + default fn methods() -> Vec { Vec::new() } } -impl PyContextProtocolImpl for T {} - impl<'p, T> PyContextProtocolImpl for T where T: PyContextProtocol<'p>, @@ -75,18 +77,22 @@ where #[doc(hidden)] pub trait PyContextEnterProtocolImpl { - fn __enter__() -> Option { + fn __enter__() -> Option; +} + +impl<'p, T> PyContextEnterProtocolImpl for T where T: PyContextProtocol<'p> { + default fn __enter__() -> Option { None } } -impl<'p, T> PyContextEnterProtocolImpl for T where T: PyContextProtocol<'p> {} - #[doc(hidden)] pub trait PyContextExitProtocolImpl { - fn __exit__() -> Option { + fn __exit__() -> Option; +} + +impl<'p, T> PyContextExitProtocolImpl for T where T: PyContextProtocol<'p> { + default fn __exit__() -> Option { None } } - -impl<'p, T> PyContextExitProtocolImpl for T where T: PyContextProtocol<'p> {} diff --git a/src/class/descr.rs b/src/class/descr.rs index 5f7e6830..c7b5b966 100644 --- a/src/class/descr.rs +++ b/src/class/descr.rs @@ -70,11 +70,13 @@ pub trait PyDescrSetNameProtocol<'p>: PyDescrProtocol<'p> { } trait PyDescrGetProtocolImpl { - fn tp_descr_get() -> Option { + fn tp_descr_get() -> Option; +} +impl<'p, T> PyDescrGetProtocolImpl for T where T: PyDescrProtocol<'p> { + default fn tp_descr_get() -> Option { None } } -impl<'p, T> PyDescrGetProtocolImpl for T where T: PyDescrProtocol<'p> {} impl PyDescrGetProtocolImpl for T where @@ -91,11 +93,13 @@ where } trait PyDescrSetProtocolImpl { - fn tp_descr_set() -> Option { + fn tp_descr_set() -> Option; +} +impl<'p, T> PyDescrSetProtocolImpl for T where T: PyDescrProtocol<'p> { + default fn tp_descr_set() -> Option { None } } -impl<'p, T> PyDescrSetProtocolImpl for T where T: PyDescrProtocol<'p> {} impl PyDescrSetProtocolImpl for T where T: for<'p> PyDescrSetProtocol<'p>, @@ -127,13 +131,16 @@ impl<'p, T> PyDescrSetNameProtocolImpl for T where T: PyDescrProtocol<'p> {} #[doc(hidden)] pub trait PyDescrProtocolImpl { - fn methods() -> Vec { - Vec::new() - } - fn tp_as_descr(_type_object: &mut ffi::PyTypeObject) {} + fn methods() -> Vec; + fn tp_as_descr(_type_object: &mut ffi::PyTypeObject); } -impl PyDescrProtocolImpl for T {} +impl PyDescrProtocolImpl for T { + default fn methods() -> Vec { + Vec::new() + } + default fn tp_as_descr(_type_object: &mut ffi::PyTypeObject) {} +} impl<'p, T> PyDescrProtocolImpl for T where diff --git a/src/class/gc.rs b/src/class/gc.rs index eaa4d901..4b69c964 100644 --- a/src/class/gc.rs +++ b/src/class/gc.rs @@ -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,15 @@ impl<'p> PyVisit<'p> { } trait PyGCTraverseProtocolImpl { - fn tp_traverse() -> Option { + fn tp_traverse() -> Option; +} + +impl<'p, T> PyGCTraverseProtocolImpl for T where T: PyGCProtocol<'p> { + default fn tp_traverse() -> Option { None } } -impl<'p, T> PyGCTraverseProtocolImpl for T where T: PyGCProtocol<'p> {} - #[doc(hidden)] impl PyGCTraverseProtocolImpl for T where @@ -105,13 +109,15 @@ where } trait PyGCClearProtocolImpl { - fn tp_clear() -> Option { + fn tp_clear() -> Option; +} + +impl<'p, T> PyGCClearProtocolImpl for T where T: PyGCProtocol<'p> { + default fn tp_clear() -> Option { None } } -impl<'p, T> PyGCClearProtocolImpl for T where T: PyGCProtocol<'p> {} - impl PyGCClearProtocolImpl for T where T: for<'p> PyGCClearProtocol<'p>, diff --git a/src/class/iter.rs b/src/class/iter.rs index 9001d53c..fcf76f2e 100644 --- a/src/class/iter.rs +++ b/src/class/iter.rs @@ -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 PyIterProtocolImpl for T {} +impl PyIterProtocolImpl for T { + default fn tp_as_iter(_typeob: &mut ffi::PyTypeObject) {} +} impl<'p, T> PyIterProtocolImpl for T where @@ -61,13 +63,15 @@ where } trait PyIterIterProtocolImpl { - fn tp_iter() -> Option { + fn tp_iter() -> Option; +} + +impl<'p, T> PyIterIterProtocolImpl for T where T: PyIterProtocol<'p> { + default fn tp_iter() -> Option { None } } -impl<'p, T> PyIterIterProtocolImpl for T where T: PyIterProtocol<'p> {} - impl PyIterIterProtocolImpl for T where T: for<'p> PyIterIterProtocol<'p>, @@ -84,13 +88,15 @@ where } trait PyIterNextProtocolImpl { - fn tp_iternext() -> Option { + fn tp_iternext() -> Option; +} + +impl<'p, T> PyIterNextProtocolImpl for T where T: PyIterProtocol<'p> { + default fn tp_iternext() -> Option { None } } -impl<'p, T> PyIterNextProtocolImpl for T where T: PyIterProtocol<'p> {} - impl PyIterNextProtocolImpl for T where T: for<'p> PyIterNextProtocol<'p>, diff --git a/src/class/mapping.rs b/src/class/mapping.rs index 61676350..64d7b57c 100644 --- a/src/class/mapping.rs +++ b/src/class/mapping.rs @@ -106,16 +106,19 @@ pub trait PyMappingReversedProtocol<'p>: PyMappingProtocol<'p> { #[doc(hidden)] pub trait PyMappingProtocolImpl { - fn tp_as_mapping() -> Option { + fn tp_as_mapping() -> Option; + fn methods() -> Vec; +} + +impl PyMappingProtocolImpl for T { + default fn tp_as_mapping() -> Option { None } - fn methods() -> Vec { + default fn methods() -> Vec { Vec::new() } } -impl PyMappingProtocolImpl for T {} - impl<'p, T> PyMappingProtocolImpl for T where T: PyMappingProtocol<'p>, @@ -154,13 +157,15 @@ where } trait PyMappingLenProtocolImpl { - fn mp_length() -> Option { + fn mp_length() -> Option; +} + +impl<'p, T> PyMappingLenProtocolImpl for T where T: PyMappingProtocol<'p> { + default fn mp_length() -> Option { None } } -impl<'p, T> PyMappingLenProtocolImpl for T where T: PyMappingProtocol<'p> {} - impl PyMappingLenProtocolImpl for T where T: for<'p> PyMappingLenProtocol<'p>, @@ -172,13 +177,15 @@ where } trait PyMappingGetItemProtocolImpl { - fn mp_subscript() -> Option { + fn mp_subscript() -> Option; +} + +impl<'p, T> PyMappingGetItemProtocolImpl for T where T: PyMappingProtocol<'p> { + default fn mp_subscript() -> Option { None } } -impl<'p, T> PyMappingGetItemProtocolImpl for T where T: PyMappingProtocol<'p> {} - impl PyMappingGetItemProtocolImpl for T where T: for<'p> PyMappingGetItemProtocol<'p>, @@ -195,13 +202,15 @@ where } trait PyMappingSetItemProtocolImpl { - fn mp_ass_subscript() -> Option { + fn mp_ass_subscript() -> Option; +} + +impl<'p, T> PyMappingSetItemProtocolImpl for T where T: PyMappingProtocol<'p> { + default fn mp_ass_subscript() -> Option { None } } -impl<'p, T> PyMappingSetItemProtocolImpl for T where T: PyMappingProtocol<'p> {} - impl PyMappingSetItemProtocolImpl for T where T: for<'p> PyMappingSetItemProtocol<'p>, @@ -215,22 +224,26 @@ where /// Returns `None` if PyMappingDelItemProtocol isn't implemented, otherwise dispatches to /// `DelSetItemDispatch` trait DeplItemDipatch { - fn mp_del_subscript() -> Option { + fn mp_del_subscript() -> Option; +} + +impl<'p, T> DeplItemDipatch for T where T: PyMappingProtocol<'p> { + default fn mp_del_subscript() -> Option { 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 { + fn det_set_dispatch() -> Option; +} + +impl DelSetItemDispatch for T where T: Sized + for<'p> PyMappingDelItemProtocol<'p> { + default fn det_set_dispatch() -> Option { py_func_del!(PyMappingDelItemProtocol, Self, __delitem__) } } -impl DelSetItemDispatch for T where T: Sized + for<'p> PyMappingDelItemProtocol<'p> {} - impl DelSetItemDispatch for T where T: for<'p> PyMappingSetItemProtocol<'p> + for<'p> PyMappingDelItemProtocol<'p>, @@ -257,27 +270,33 @@ where #[doc(hidden)] pub trait PyMappingContainsProtocolImpl { - fn __contains__() -> Option { + fn __contains__() -> Option; +} + +impl<'p, T> PyMappingContainsProtocolImpl for T where T: PyMappingProtocol<'p> { + default fn __contains__() -> Option { None } } -impl<'p, T> PyMappingContainsProtocolImpl for T where T: PyMappingProtocol<'p> {} - #[doc(hidden)] pub trait PyMappingReversedProtocolImpl { - fn __reversed__() -> Option { + fn __reversed__() -> Option; +} + +impl<'p, T> PyMappingReversedProtocolImpl for T where T: PyMappingProtocol<'p> { + default fn __reversed__() -> Option { None } } -impl<'p, T> PyMappingReversedProtocolImpl for T where T: PyMappingProtocol<'p> {} - #[doc(hidden)] pub trait PyMappingIterProtocolImpl { - fn __iter__() -> Option { + fn __iter__() -> Option; +} + +impl<'p, T> PyMappingIterProtocolImpl for T where T: PyMappingProtocol<'p> { + default fn __iter__() -> Option { None } } - -impl<'p, T> PyMappingIterProtocolImpl for T where T: PyMappingProtocol<'p> {} diff --git a/src/class/number.rs b/src/class/number.rs index 2ee3a57d..0ab162e7 100644 --- a/src/class/number.rs +++ b/src/class/number.rs @@ -622,10 +622,15 @@ pub trait PyNumberIndexProtocol<'p>: PyNumberProtocol<'p> { #[doc(hidden)] pub trait PyNumberProtocolImpl: PyObjectProtocolImpl { - fn methods() -> Vec { + fn methods() -> Vec; + fn tp_as_number() -> Option; +} + +impl<'p, T> PyNumberProtocolImpl for T { + default fn methods() -> Vec { Vec::new() } - fn tp_as_number() -> Option { + default fn tp_as_number() -> Option { if let Some(nb_bool) = ::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,15 @@ where } trait PyNumberAddProtocolImpl { - fn nb_add() -> Option { + fn nb_add() -> Option; +} + +impl<'p, T> PyNumberAddProtocolImpl for T where T: PyNumberProtocol<'p> { + default fn nb_add() -> Option { None } } -impl<'p, T> PyNumberAddProtocolImpl for T where T: PyNumberProtocol<'p> {} - impl PyNumberAddProtocolImpl for T where T: for<'p> PyNumberAddProtocol<'p>, @@ -765,13 +770,15 @@ where } trait PyNumberSubProtocolImpl { - fn nb_subtract() -> Option { + fn nb_subtract() -> Option; +} + +impl<'p, T> PyNumberSubProtocolImpl for T where T: PyNumberProtocol<'p> { + default fn nb_subtract() -> Option { None } } -impl<'p, T> PyNumberSubProtocolImpl for T where T: PyNumberProtocol<'p> {} - impl PyNumberSubProtocolImpl for T where T: for<'p> PyNumberSubProtocol<'p>, @@ -787,13 +794,15 @@ where } trait PyNumberMulProtocolImpl { - fn nb_multiply() -> Option { + fn nb_multiply() -> Option; +} + +impl<'p, T> PyNumberMulProtocolImpl for T where T: PyNumberProtocol<'p> { + default fn nb_multiply() -> Option { None } } -impl<'p, T> PyNumberMulProtocolImpl for T where T: PyNumberProtocol<'p> {} - impl PyNumberMulProtocolImpl for T where T: for<'p> PyNumberMulProtocol<'p>, @@ -809,13 +818,15 @@ where } trait PyNumberMatmulProtocolImpl { - fn nb_matrix_multiply() -> Option { + fn nb_matrix_multiply() -> Option; +} + +impl<'p, T> PyNumberMatmulProtocolImpl for T where T: PyNumberProtocol<'p> { + default fn nb_matrix_multiply() -> Option { None } } -impl<'p, T> PyNumberMatmulProtocolImpl for T where T: PyNumberProtocol<'p> {} - impl PyNumberMatmulProtocolImpl for T where T: for<'p> PyNumberMatmulProtocol<'p>, @@ -831,13 +842,15 @@ where } trait PyNumberTruedivProtocolImpl { - fn nb_true_divide() -> Option { + fn nb_true_divide() -> Option; +} + +impl<'p, T> PyNumberTruedivProtocolImpl for T where T: PyNumberProtocol<'p> { + default fn nb_true_divide() -> Option { None } } -impl<'p, T> PyNumberTruedivProtocolImpl for T where T: PyNumberProtocol<'p> {} - impl PyNumberTruedivProtocolImpl for T where T: for<'p> PyNumberTruedivProtocol<'p>, @@ -853,13 +866,15 @@ where } trait PyNumberFloordivProtocolImpl { - fn nb_floor_divide() -> Option { + fn nb_floor_divide() -> Option; +} + +impl<'p, T> PyNumberFloordivProtocolImpl for T where T: PyNumberProtocol<'p> { + default fn nb_floor_divide() -> Option { None } } -impl<'p, T> PyNumberFloordivProtocolImpl for T where T: PyNumberProtocol<'p> {} - impl PyNumberFloordivProtocolImpl for T where T: for<'p> PyNumberFloordivProtocol<'p>, @@ -875,13 +890,15 @@ where } trait PyNumberModProtocolImpl { - fn nb_remainder() -> Option { + fn nb_remainder() -> Option; +} + +impl<'p, T> PyNumberModProtocolImpl for T where T: PyNumberProtocol<'p> { + default fn nb_remainder() -> Option { None } } -impl<'p, T> PyNumberModProtocolImpl for T where T: PyNumberProtocol<'p> {} - impl PyNumberModProtocolImpl for T where T: for<'p> PyNumberModProtocol<'p>, @@ -897,13 +914,15 @@ where } trait PyNumberDivmodProtocolImpl { - fn nb_divmod() -> Option { + fn nb_divmod() -> Option; +} + +impl<'p, T> PyNumberDivmodProtocolImpl for T where T: PyNumberProtocol<'p> { + default fn nb_divmod() -> Option { None } } -impl<'p, T> PyNumberDivmodProtocolImpl for T where T: PyNumberProtocol<'p> {} - impl PyNumberDivmodProtocolImpl for T where T: for<'p> PyNumberDivmodProtocol<'p>, @@ -919,13 +938,15 @@ where } trait PyNumberPowProtocolImpl { - fn nb_power() -> Option { + fn nb_power() -> Option; +} + +impl<'p, T> PyNumberPowProtocolImpl for T where T: PyNumberProtocol<'p> { + default fn nb_power() -> Option { None } } -impl<'p, T> PyNumberPowProtocolImpl for T where T: PyNumberProtocol<'p> {} - impl PyNumberPowProtocolImpl for T where T: for<'p> PyNumberPowProtocol<'p>, @@ -941,13 +962,15 @@ where } trait PyNumberLShiftProtocolImpl { - fn nb_lshift() -> Option { + fn nb_lshift() -> Option; +} + +impl<'p, T> PyNumberLShiftProtocolImpl for T where T: PyNumberProtocol<'p> { + default fn nb_lshift() -> Option { None } } -impl<'p, T> PyNumberLShiftProtocolImpl for T where T: PyNumberProtocol<'p> {} - impl PyNumberLShiftProtocolImpl for T where T: for<'p> PyNumberLShiftProtocol<'p>, @@ -963,13 +986,15 @@ where } trait PyNumberRShiftProtocolImpl { - fn nb_rshift() -> Option { + fn nb_rshift() -> Option; +} + +impl<'p, T> PyNumberRShiftProtocolImpl for T where T: PyNumberProtocol<'p> { + default fn nb_rshift() -> Option { None } } -impl<'p, T> PyNumberRShiftProtocolImpl for T where T: PyNumberProtocol<'p> {} - impl PyNumberRShiftProtocolImpl for T where T: for<'p> PyNumberRShiftProtocol<'p>, @@ -985,13 +1010,15 @@ where } trait PyNumberAndProtocolImpl { - fn nb_and() -> Option { + fn nb_and() -> Option; +} + +impl<'p, T> PyNumberAndProtocolImpl for T where T: PyNumberProtocol<'p> { + default fn nb_and() -> Option { None } } -impl<'p, T> PyNumberAndProtocolImpl for T where T: PyNumberProtocol<'p> {} - impl PyNumberAndProtocolImpl for T where T: for<'p> PyNumberAndProtocol<'p>, @@ -1007,13 +1034,15 @@ where } trait PyNumberXorProtocolImpl { - fn nb_xor() -> Option { + fn nb_xor() -> Option; +} + +impl<'p, T> PyNumberXorProtocolImpl for T where T: PyNumberProtocol<'p> { + default fn nb_xor() -> Option { None } } -impl<'p, T> PyNumberXorProtocolImpl for T where T: PyNumberProtocol<'p> {} - impl PyNumberXorProtocolImpl for T where T: for<'p> PyNumberXorProtocol<'p>, @@ -1029,13 +1058,15 @@ where } trait PyNumberOrProtocolImpl { - fn nb_or() -> Option { + fn nb_or() -> Option; +} + +impl<'p, T> PyNumberOrProtocolImpl for T where T: PyNumberProtocol<'p> { + default fn nb_or() -> Option { None } } -impl<'p, T> PyNumberOrProtocolImpl for T where T: PyNumberProtocol<'p> {} - impl PyNumberOrProtocolImpl for T where T: for<'p> PyNumberOrProtocol<'p>, @@ -1051,13 +1082,15 @@ where } trait PyNumberIAddProtocolImpl { - fn nb_inplace_add() -> Option { + fn nb_inplace_add() -> Option; +} + +impl<'p, T> PyNumberIAddProtocolImpl for T where T: PyNumberProtocol<'p> { + default fn nb_inplace_add() -> Option { None } } -impl<'p, T> PyNumberIAddProtocolImpl for T where T: PyNumberProtocol<'p> {} - impl PyNumberIAddProtocolImpl for T where T: for<'p> PyNumberIAddProtocol<'p>, @@ -1068,13 +1101,15 @@ where } trait PyNumberISubProtocolImpl { - fn nb_inplace_subtract() -> Option { + fn nb_inplace_subtract() -> Option; +} + +impl<'p, T> PyNumberISubProtocolImpl for T where T: PyNumberProtocol<'p> { + default fn nb_inplace_subtract() -> Option { None } } -impl<'p, T> PyNumberISubProtocolImpl for T where T: PyNumberProtocol<'p> {} - impl PyNumberISubProtocolImpl for T where T: for<'p> PyNumberISubProtocol<'p>, @@ -1085,13 +1120,15 @@ where } trait PyNumberIMulProtocolImpl { - fn nb_inplace_multiply() -> Option { + fn nb_inplace_multiply() -> Option; +} + +impl<'p, T> PyNumberIMulProtocolImpl for T where T: PyNumberProtocol<'p> { + default fn nb_inplace_multiply() -> Option { None } } -impl<'p, T> PyNumberIMulProtocolImpl for T where T: PyNumberProtocol<'p> {} - impl PyNumberIMulProtocolImpl for T where T: for<'p> PyNumberIMulProtocol<'p>, @@ -1102,13 +1139,15 @@ where } trait PyNumberIMatmulProtocolImpl { - fn nb_inplace_matrix_multiply() -> Option { + fn nb_inplace_matrix_multiply() -> Option; +} + +impl<'p, T> PyNumberIMatmulProtocolImpl for T where T: PyNumberProtocol<'p> { + default fn nb_inplace_matrix_multiply() -> Option { None } } -impl<'p, T> PyNumberIMatmulProtocolImpl for T where T: PyNumberProtocol<'p> {} - impl PyNumberIMatmulProtocolImpl for T where T: for<'p> PyNumberIMatmulProtocol<'p>, @@ -1119,13 +1158,15 @@ where } trait PyNumberITruedivProtocolImpl { - fn nb_inplace_true_divide() -> Option { + fn nb_inplace_true_divide() -> Option; +} + +impl<'p, T> PyNumberITruedivProtocolImpl for T where T: PyNumberProtocol<'p> { + default fn nb_inplace_true_divide() -> Option { None } } -impl<'p, T> PyNumberITruedivProtocolImpl for T where T: PyNumberProtocol<'p> {} - impl PyNumberITruedivProtocolImpl for T where T: for<'p> PyNumberITruedivProtocol<'p>, @@ -1136,13 +1177,15 @@ where } trait PyNumberIFloordivProtocolImpl { - fn nb_inplace_floor_divide() -> Option { + fn nb_inplace_floor_divide() -> Option; +} + +impl<'p, T> PyNumberIFloordivProtocolImpl for T where T: PyNumberProtocol<'p> { + default fn nb_inplace_floor_divide() -> Option { None } } -impl<'p, T> PyNumberIFloordivProtocolImpl for T where T: PyNumberProtocol<'p> {} - impl PyNumberIFloordivProtocolImpl for T where T: for<'p> PyNumberIFloordivProtocol<'p>, @@ -1153,13 +1196,15 @@ where } trait PyNumberIModProtocolImpl { - fn nb_inplace_remainder() -> Option { + fn nb_inplace_remainder() -> Option; +} + +impl<'p, T> PyNumberIModProtocolImpl for T where T: PyNumberProtocol<'p> { + default fn nb_inplace_remainder() -> Option { None } } -impl<'p, T> PyNumberIModProtocolImpl for T where T: PyNumberProtocol<'p> {} - impl PyNumberIModProtocolImpl for T where T: for<'p> PyNumberIModProtocol<'p>, @@ -1170,13 +1215,15 @@ where } trait PyNumberIPowProtocolImpl { - fn nb_inplace_power() -> Option { + fn nb_inplace_power() -> Option; +} + +impl<'p, T> PyNumberIPowProtocolImpl for T where T: PyNumberProtocol<'p> { + default fn nb_inplace_power() -> Option { None } } -impl<'p, T> PyNumberIPowProtocolImpl for T where T: PyNumberProtocol<'p> {} - impl PyNumberIPowProtocolImpl for T where T: for<'p> PyNumberIPowProtocol<'p>, @@ -1187,13 +1234,15 @@ where } trait PyNumberILShiftProtocolImpl { - fn nb_inplace_lshift() -> Option { + fn nb_inplace_lshift() -> Option; +} + +impl<'p, T> PyNumberILShiftProtocolImpl for T where T: PyNumberProtocol<'p> { + default fn nb_inplace_lshift() -> Option { None } } -impl<'p, T> PyNumberILShiftProtocolImpl for T where T: PyNumberProtocol<'p> {} - impl PyNumberILShiftProtocolImpl for T where T: for<'p> PyNumberILShiftProtocol<'p>, @@ -1204,13 +1253,15 @@ where } trait PyNumberIRShiftProtocolImpl { - fn nb_inplace_rshift() -> Option { + fn nb_inplace_rshift() -> Option; +} + +impl<'p, T> PyNumberIRShiftProtocolImpl for T where T: PyNumberProtocol<'p> { + default fn nb_inplace_rshift() -> Option { None } } -impl<'p, T> PyNumberIRShiftProtocolImpl for T where T: PyNumberProtocol<'p> {} - impl PyNumberIRShiftProtocolImpl for T where T: for<'p> PyNumberIRShiftProtocol<'p>, @@ -1221,13 +1272,15 @@ where } trait PyNumberIAndProtocolImpl { - fn nb_inplace_and() -> Option { + fn nb_inplace_and() -> Option; +} + +impl<'p, T> PyNumberIAndProtocolImpl for T where T: PyNumberProtocol<'p> { + default fn nb_inplace_and() -> Option { None } } -impl<'p, T> PyNumberIAndProtocolImpl for T where T: PyNumberProtocol<'p> {} - impl PyNumberIAndProtocolImpl for T where T: for<'p> PyNumberIAndProtocol<'p>, @@ -1238,13 +1291,15 @@ where } trait PyNumberIXorProtocolImpl { - fn nb_inplace_xor() -> Option { + fn nb_inplace_xor() -> Option; +} + +impl<'p, T> PyNumberIXorProtocolImpl for T where T: PyNumberProtocol<'p> { + default fn nb_inplace_xor() -> Option { None } } -impl<'p, T> PyNumberIXorProtocolImpl for T where T: PyNumberProtocol<'p> {} - impl PyNumberIXorProtocolImpl for T where T: for<'p> PyNumberIXorProtocol<'p>, @@ -1255,13 +1310,15 @@ where } trait PyNumberIOrProtocolImpl { - fn nb_inplace_or() -> Option { + fn nb_inplace_or() -> Option; +} + +impl<'p, T> PyNumberIOrProtocolImpl for T where T: PyNumberProtocol<'p> { + default fn nb_inplace_or() -> Option { None } } -impl<'p, T> PyNumberIOrProtocolImpl for T where T: PyNumberProtocol<'p> {} - impl PyNumberIOrProtocolImpl for T where T: for<'p> PyNumberIOrProtocol<'p>, @@ -1273,13 +1330,15 @@ where #[doc(hidden)] pub trait PyNumberRAddProtocolImpl { - fn __radd__() -> Option { + fn __radd__() -> Option; +} + +impl<'p, T> PyNumberRAddProtocolImpl for T where T: PyNumberProtocol<'p> { + default fn __radd__() -> Option { None } } -impl<'p, T> PyNumberRAddProtocolImpl for T where T: PyNumberProtocol<'p> {} - #[doc(hidden)] pub trait PyNumberRSubProtocolImpl { fn __rsub__() -> Option { @@ -1291,120 +1350,146 @@ impl<'p, T> PyNumberRSubProtocolImpl for T where T: PyNumberProtocol<'p> {} #[doc(hidden)] pub trait PyNumberRMulProtocolImpl { - fn __rmul__() -> Option { + fn __rmul__() -> Option; +} + +impl<'p, T> PyNumberRMulProtocolImpl for T where T: PyNumberProtocol<'p> { + default fn __rmul__() -> Option { None } } -impl<'p, T> PyNumberRMulProtocolImpl for T where T: PyNumberProtocol<'p> {} - #[doc(hidden)] pub trait PyNumberRMatmulProtocolImpl { - fn __rmatmul__() -> Option { + fn __rmatmul__() -> Option; +} + +impl<'p, T> PyNumberRMatmulProtocolImpl for T where T: PyNumberProtocol<'p> { + default fn __rmatmul__() -> Option { None } } -impl<'p, T> PyNumberRMatmulProtocolImpl for T where T: PyNumberProtocol<'p> {} - #[doc(hidden)] pub trait PyNumberRTruedivProtocolImpl { - fn __rtruediv__() -> Option { + fn __rtruediv__() -> Option; +} + +impl<'p, T> PyNumberRTruedivProtocolImpl for T where T: PyNumberProtocol<'p> { + default fn __rtruediv__() -> Option { None } } -impl<'p, T> PyNumberRTruedivProtocolImpl for T where T: PyNumberProtocol<'p> {} - #[doc(hidden)] pub trait PyNumberRFloordivProtocolImpl { - fn __rfloordiv__() -> Option { + fn __rfloordiv__() -> Option; +} + +impl<'p, T> PyNumberRFloordivProtocolImpl for T where T: PyNumberProtocol<'p> { + default fn __rfloordiv__() -> Option { None } } -impl<'p, T> PyNumberRFloordivProtocolImpl for T where T: PyNumberProtocol<'p> {} - #[doc(hidden)] pub trait PyNumberRModProtocolImpl { - fn __rmod__() -> Option { + fn __rmod__() -> Option; +} + +impl<'p, T> PyNumberRModProtocolImpl for T where T: PyNumberProtocol<'p> { + default fn __rmod__() -> Option { None } } -impl<'p, T> PyNumberRModProtocolImpl for T where T: PyNumberProtocol<'p> {} - #[doc(hidden)] pub trait PyNumberRDivmodProtocolImpl { - fn __rdivmod__() -> Option { + fn __rdivmod__() -> Option; +} + +impl<'p, T> PyNumberRDivmodProtocolImpl for T where T: PyNumberProtocol<'p> { + default fn __rdivmod__() -> Option { None } } -impl<'p, T> PyNumberRDivmodProtocolImpl for T where T: PyNumberProtocol<'p> {} - #[doc(hidden)] pub trait PyNumberRPowProtocolImpl { - fn __rpow__() -> Option { + fn __rpow__() -> Option; +} + +impl<'p, T> PyNumberRPowProtocolImpl for T where T: PyNumberProtocol<'p> { + default fn __rpow__() -> Option { None } } -impl<'p, T> PyNumberRPowProtocolImpl for T where T: PyNumberProtocol<'p> {} - #[doc(hidden)] pub trait PyNumberRLShiftProtocolImpl { - fn __rlshift__() -> Option { + fn __rlshift__() -> Option; +} + +impl<'p, T> PyNumberRLShiftProtocolImpl for T where T: PyNumberProtocol<'p> { + default fn __rlshift__() -> Option { None } } -impl<'p, T> PyNumberRLShiftProtocolImpl for T where T: PyNumberProtocol<'p> {} - #[doc(hidden)] pub trait PyNumberRRShiftProtocolImpl { - fn __rrshift__() -> Option { + fn __rrshift__() -> Option; +} + +impl<'p, T> PyNumberRRShiftProtocolImpl for T where T: PyNumberProtocol<'p> { + default fn __rrshift__() -> Option { None } } -impl<'p, T> PyNumberRRShiftProtocolImpl for T where T: PyNumberProtocol<'p> {} - #[doc(hidden)] pub trait PyNumberRAndProtocolImpl { - fn __rand__() -> Option { + fn __rand__() -> Option; +} + +impl<'p, T> PyNumberRAndProtocolImpl for T where T: PyNumberProtocol<'p> { + default fn __rand__() -> Option { None } } -impl<'p, T> PyNumberRAndProtocolImpl for T where T: PyNumberProtocol<'p> {} - #[doc(hidden)] pub trait PyNumberRXorProtocolImpl { - fn __rxor__() -> Option { + fn __rxor__() -> Option; +} + +impl<'p, T> PyNumberRXorProtocolImpl for T where T: PyNumberProtocol<'p> { + default fn __rxor__() -> Option { None } } -impl<'p, T> PyNumberRXorProtocolImpl for T where T: PyNumberProtocol<'p> {} - #[doc(hidden)] pub trait PyNumberROrProtocolImpl { - fn __ror__() -> Option { + fn __ror__() -> Option; +} + +impl<'p, T> PyNumberROrProtocolImpl for T where T: PyNumberProtocol<'p> { + default fn __ror__() -> Option { None } } -impl<'p, T> PyNumberROrProtocolImpl for T where T: PyNumberProtocol<'p> {} - trait PyNumberNegProtocolImpl { - fn nb_negative() -> Option { + fn nb_negative() -> Option; +} + +impl<'p, T> PyNumberNegProtocolImpl for T where T: PyNumberProtocol<'p> { + default fn nb_negative() -> Option { None } } -impl<'p, T> PyNumberNegProtocolImpl for T where T: PyNumberProtocol<'p> {} - impl PyNumberNegProtocolImpl for T where T: for<'p> PyNumberNegProtocol<'p>, @@ -1421,13 +1506,15 @@ where } trait PyNumberPosProtocolImpl { - fn nb_positive() -> Option { + fn nb_positive() -> Option; +} + +impl<'p, T> PyNumberPosProtocolImpl for T where T: PyNumberProtocol<'p> { + default fn nb_positive() -> Option { None } } -impl<'p, T> PyNumberPosProtocolImpl for T where T: PyNumberProtocol<'p> {} - impl PyNumberPosProtocolImpl for T where T: for<'p> PyNumberPosProtocol<'p>, @@ -1443,13 +1530,15 @@ where } trait PyNumberAbsProtocolImpl { - fn nb_absolute() -> Option { + fn nb_absolute() -> Option; +} + +impl<'p, T> PyNumberAbsProtocolImpl for T where T: PyNumberProtocol<'p> { + default fn nb_absolute() -> Option { None } } -impl<'p, T> PyNumberAbsProtocolImpl for T where T: PyNumberProtocol<'p> {} - impl PyNumberAbsProtocolImpl for T where T: for<'p> PyNumberAbsProtocol<'p>, @@ -1465,13 +1554,15 @@ where } trait PyNumberInvertProtocolImpl { - fn nb_invert() -> Option { + fn nb_invert() -> Option; +} + +impl<'p, T> PyNumberInvertProtocolImpl for T where T: PyNumberProtocol<'p> { + default fn nb_invert() -> Option { None } } -impl<'p, T> PyNumberInvertProtocolImpl for T where T: PyNumberProtocol<'p> {} - impl PyNumberInvertProtocolImpl for T where T: for<'p> PyNumberInvertProtocol<'p>, @@ -1487,13 +1578,15 @@ where } trait PyNumberIntProtocolImpl { - fn nb_int() -> Option { + fn nb_int() -> Option; +} + +impl<'p, T> PyNumberIntProtocolImpl for T where T: PyNumberProtocol<'p> { + default fn nb_int() -> Option { None } } -impl<'p, T> PyNumberIntProtocolImpl for T where T: PyNumberProtocol<'p> {} - impl PyNumberIntProtocolImpl for T where T: for<'p> PyNumberIntProtocol<'p>, @@ -1509,13 +1602,15 @@ where } trait PyNumberFloatProtocolImpl { - fn nb_float() -> Option { + fn nb_float() -> Option; +} + +impl<'p, T> PyNumberFloatProtocolImpl for T where T: PyNumberProtocol<'p> { + default fn nb_float() -> Option { None } } -impl<'p, T> PyNumberFloatProtocolImpl for T where T: PyNumberProtocol<'p> {} - impl PyNumberFloatProtocolImpl for T where T: for<'p> PyNumberFloatProtocol<'p>, @@ -1531,13 +1626,15 @@ where } trait PyNumberIndexProtocolImpl { - fn nb_index() -> Option { + fn nb_index() -> Option; +} + +impl<'p, T> PyNumberIndexProtocolImpl for T where T: PyNumberProtocol<'p> { + default fn nb_index() -> Option { None } } -impl<'p, T> PyNumberIndexProtocolImpl for T where T: PyNumberProtocol<'p> {} - impl PyNumberIndexProtocolImpl for T where T: for<'p> PyNumberIndexProtocol<'p>, @@ -1553,17 +1650,21 @@ where } trait PyNumberComplexProtocolImpl { - fn __complex__() -> Option { + fn __complex__() -> Option; +} + +impl<'p, T> PyNumberComplexProtocolImpl for T where T: PyNumberProtocol<'p> { + default fn __complex__() -> Option { None } } -impl<'p, T> PyNumberComplexProtocolImpl for T where T: PyNumberProtocol<'p> {} - trait PyNumberRoundProtocolImpl { - fn __round__() -> Option { + fn __round__() -> Option; +} + +impl<'p, T> PyNumberRoundProtocolImpl for T where T: PyNumberProtocol<'p> { + default fn __round__() -> Option { None } } - -impl<'p, T> PyNumberRoundProtocolImpl for T where T: PyNumberProtocol<'p> {} diff --git a/src/class/pyasync.rs b/src/class/pyasync.rs index 9afb72c1..f977fadf 100644 --- a/src/class/pyasync.rs +++ b/src/class/pyasync.rs @@ -91,17 +91,20 @@ pub trait PyAsyncAexitProtocol<'p>: PyAsyncProtocol<'p> { #[doc(hidden)] pub trait PyAsyncProtocolImpl { - fn tp_as_async() -> Option { + fn tp_as_async() -> Option; + fn methods() -> Vec; +} + +impl PyAsyncProtocolImpl for T { + default fn tp_as_async() -> Option { None } - fn methods() -> Vec { + default fn methods() -> Vec { Vec::new() } } -impl PyAsyncProtocolImpl for T {} - impl<'p, T> PyAsyncProtocolImpl for T where T: PyAsyncProtocol<'p>, @@ -131,13 +134,15 @@ where } trait PyAsyncAwaitProtocolImpl { - fn am_await() -> Option { + fn am_await() -> Option; +} + +impl<'p, T> PyAsyncAwaitProtocolImpl for T where T: PyAsyncProtocol<'p> { + default fn am_await() -> Option { None } } -impl<'p, T> PyAsyncAwaitProtocolImpl for T where T: PyAsyncProtocol<'p> {} - impl PyAsyncAwaitProtocolImpl for T where T: for<'p> PyAsyncAwaitProtocol<'p>, @@ -154,13 +159,15 @@ where } trait PyAsyncAiterProtocolImpl { - fn am_aiter() -> Option { + fn am_aiter() -> Option; +} + +impl<'p, T> PyAsyncAiterProtocolImpl for T where T: PyAsyncProtocol<'p> { + default fn am_aiter() -> Option { None } } -impl<'p, T> PyAsyncAiterProtocolImpl for T where T: PyAsyncProtocol<'p> {} - impl PyAsyncAiterProtocolImpl for T where T: for<'p> PyAsyncAiterProtocol<'p>, @@ -177,13 +184,15 @@ where } trait PyAsyncAnextProtocolImpl { - fn am_anext() -> Option { + fn am_anext() -> Option; +} + +impl<'p, T> PyAsyncAnextProtocolImpl for T where T: PyAsyncProtocol<'p> { + default fn am_anext() -> Option { None } } -impl<'p, T> PyAsyncAnextProtocolImpl for T where T: PyAsyncProtocol<'p> {} - mod anext { use super::{PyAsyncAnextProtocol, PyAsyncAnextProtocolImpl}; use crate::callback::CallbackConverter; @@ -233,17 +242,21 @@ mod anext { } trait PyAsyncAenterProtocolImpl { - fn __aenter__() -> Option { + fn __aenter__() -> Option; +} + +impl<'p, T> PyAsyncAenterProtocolImpl for T where T: PyAsyncProtocol<'p> { + default fn __aenter__() -> Option { None } } -impl<'p, T> PyAsyncAenterProtocolImpl for T where T: PyAsyncProtocol<'p> {} - trait PyAsyncAexitProtocolImpl { - fn __aexit__() -> Option { + fn __aexit__() -> Option; +} + +impl<'p, T> PyAsyncAexitProtocolImpl for T where T: PyAsyncProtocol<'p> { + default fn __aexit__() -> Option { None } } - -impl<'p, T> PyAsyncAexitProtocolImpl for T where T: PyAsyncProtocol<'p> {} diff --git a/src/class/sequence.rs b/src/class/sequence.rs index 1f969722..082323b6 100644 --- a/src/class/sequence.rs +++ b/src/class/sequence.rs @@ -134,13 +134,15 @@ pub trait PySequenceInplaceRepeatProtocol<'p>: PySequenceProtocol<'p> + IntoPy

Option { + fn tp_as_sequence() -> Option; +} + +impl PySequenceProtocolImpl for T { + default fn tp_as_sequence() -> Option { None } } -impl PySequenceProtocolImpl for T {} - impl<'p, T> PySequenceProtocolImpl for T where T: PySequenceProtocol<'p>, @@ -162,13 +164,15 @@ where } trait PySequenceLenProtocolImpl { - fn sq_length() -> Option { + fn sq_length() -> Option; +} + +impl<'p, T> PySequenceLenProtocolImpl for T where T: PySequenceProtocol<'p> { + default fn sq_length() -> Option { None } } -impl<'p, T> PySequenceLenProtocolImpl for T where T: PySequenceProtocol<'p> {} - impl PySequenceLenProtocolImpl for T where T: for<'p> PySequenceLenProtocol<'p>, @@ -179,13 +183,15 @@ where } trait PySequenceGetItemProtocolImpl { - fn sq_item() -> Option { + fn sq_item() -> Option; +} + +impl<'p, T> PySequenceGetItemProtocolImpl for T where T: PySequenceProtocol<'p> { + default fn sq_item() -> Option { None } } -impl<'p, T> PySequenceGetItemProtocolImpl for T where T: PySequenceProtocol<'p> {} - impl PySequenceGetItemProtocolImpl for T where T: for<'p> PySequenceGetItemProtocol<'p>, @@ -201,13 +207,15 @@ where } trait PySequenceSetItemProtocolImpl { - fn sq_ass_item() -> Option { + fn sq_ass_item() -> Option; +} + +impl<'p, T> PySequenceSetItemProtocolImpl for T where T: PySequenceProtocol<'p> { + default fn sq_ass_item() -> Option { None } } -impl<'p, T> PySequenceSetItemProtocolImpl for T where T: PySequenceProtocol<'p> {} - impl PySequenceSetItemProtocolImpl for T where T: for<'p> PySequenceSetItemProtocol<'p>, @@ -275,13 +283,15 @@ mod sq_ass_item_impl { } trait DelItem { - fn del_item() -> Option { + fn del_item() -> Option; + } + + impl<'p, T> DelItem for T where T: PySequenceProtocol<'p> { + default fn del_item() -> Option { None } } - impl<'p, T> DelItem for T where T: PySequenceProtocol<'p> {} - impl DelItem for T where T: for<'p> PySequenceDelItemProtocol<'p>, @@ -321,13 +331,15 @@ mod sq_ass_item_impl { } trait DelSetItem { - fn del_set_item() -> Option { + fn del_set_item() -> Option; + } + + impl<'p, T> DelSetItem for T where T: PySequenceProtocol<'p> { + default fn del_set_item() -> Option { None } } - impl<'p, T> DelSetItem for T where T: PySequenceProtocol<'p> {} - impl DelSetItem for T where T: for<'p> PySequenceSetItemProtocol<'p> + for<'p> PySequenceDelItemProtocol<'p>, @@ -368,13 +380,15 @@ mod sq_ass_item_impl { } trait PySequenceContainsProtocolImpl { - fn sq_contains() -> Option { + fn sq_contains() -> Option; +} + +impl<'p, T> PySequenceContainsProtocolImpl for T where T: PySequenceProtocol<'p> { + default fn sq_contains() -> Option { None } } -impl<'p, T> PySequenceContainsProtocolImpl for T where T: PySequenceProtocol<'p> {} - impl PySequenceContainsProtocolImpl for T where T: for<'p> PySequenceContainsProtocol<'p>, @@ -391,13 +405,15 @@ where } trait PySequenceConcatProtocolImpl { - fn sq_concat() -> Option { + fn sq_concat() -> Option; +} + +impl<'p, T> PySequenceConcatProtocolImpl for T where T: PySequenceProtocol<'p> { + default fn sq_concat() -> Option { None } } -impl<'p, T> PySequenceConcatProtocolImpl for T where T: PySequenceProtocol<'p> {} - impl PySequenceConcatProtocolImpl for T where T: for<'p> PySequenceConcatProtocol<'p>, @@ -413,13 +429,15 @@ where } trait PySequenceRepeatProtocolImpl { - fn sq_repeat() -> Option { + fn sq_repeat() -> Option; +} + +impl<'p, T> PySequenceRepeatProtocolImpl for T where T: PySequenceProtocol<'p> { + default fn sq_repeat() -> Option { None } } -impl<'p, T> PySequenceRepeatProtocolImpl for T where T: PySequenceProtocol<'p> {} - impl PySequenceRepeatProtocolImpl for T where T: for<'p> PySequenceRepeatProtocol<'p>, @@ -435,13 +453,15 @@ where } trait PySequenceInplaceConcatProtocolImpl { - fn sq_inplace_concat() -> Option { + fn sq_inplace_concat() -> Option; +} + +impl<'p, T> PySequenceInplaceConcatProtocolImpl for T where T: PySequenceProtocol<'p> { + default fn sq_inplace_concat() -> Option { None } } -impl<'p, T> PySequenceInplaceConcatProtocolImpl for T where T: PySequenceProtocol<'p> {} - impl PySequenceInplaceConcatProtocolImpl for T where T: for<'p> PySequenceInplaceConcatProtocol<'p>, @@ -457,13 +477,15 @@ where } trait PySequenceInplaceRepeatProtocolImpl { - fn sq_inplace_repeat() -> Option { + fn sq_inplace_repeat() -> Option; +} + +impl<'p, T> PySequenceInplaceRepeatProtocolImpl for T where T: PySequenceProtocol<'p> { + default fn sq_inplace_repeat() -> Option { None } } -impl<'p, T> PySequenceInplaceRepeatProtocolImpl for T where T: PySequenceProtocol<'p> {} - impl PySequenceInplaceRepeatProtocolImpl for T where T: for<'p> PySequenceInplaceRepeatProtocol<'p>, diff --git a/src/conversion.rs b/src/conversion.rs index a3bca117..15ccdabd 100644 --- a/src/conversion.rs +++ b/src/conversion.rs @@ -96,6 +96,12 @@ 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(&self, py: Python, f: F) -> R + where + F: FnOnce(*mut ffi::PyObject) -> R; +} + +impl ToBorrowedObject for T where T: ToPyObject { + default fn with_borrowed_ptr(&self, py: Python, f: F) -> R where F: FnOnce(*mut ffi::PyObject) -> R, { @@ -108,8 +114,6 @@ pub trait ToBorrowedObject: ToPyObject { } } -impl ToBorrowedObject for T where T: ToPyObject {} - impl ToBorrowedObject for T where T: ToPyObject + AsPyPointer, diff --git a/src/instance.rs b/src/instance.rs index 68bd45ec..779d1861 100644 --- a/src/instance.rs +++ b/src/instance.rs @@ -359,13 +359,18 @@ impl Py { /// Specialization workaround trait AsPyRefDispatch: 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 AsPyRefDispatch for Py { + 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: AsPyPointer { } } -impl AsPyRefDispatch for Py {} - impl AsPyRefDispatch for Py { fn as_ref_dispatch(&self, _py: Python) -> &T { unsafe { &*(self as *const instance::Py 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) { - unsafe { ffi::Py_DECREF(borrowed.data) }; - } + fn drop_impl(borrowed: &mut ManagedPyRef); } /// 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 ManagedPyRefDispatch for T {} +impl 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) { + 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. From 33bf37d3d8ca08d3af39de22547e32e7c8eb0f54 Mon Sep 17 00:00:00 2001 From: Martin Larralde Date: Mon, 7 Oct 2019 17:12:32 +0200 Subject: [PATCH 2/2] Run `cargo fmt` on source code and update `CHANGELOG.md` --- CHANGELOG.md | 1 + pyo3-derive-backend/src/pymethod.rs | 6 +- src/class/basic.rs | 55 +++++-- src/class/buffer.rs | 5 +- src/class/context.rs | 10 +- src/class/descr.rs | 10 +- src/class/gc.rs | 10 +- src/class/iter.rs | 10 +- src/class/mapping.rs | 40 ++++- src/class/number.rs | 245 ++++++++++++++++++++++------ src/class/pyasync.rs | 25 ++- src/class/sequence.rs | 50 ++++-- src/conversion.rs | 5 +- 13 files changed, 376 insertions(+), 96 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index df50e9d2..5ae40e68 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -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 diff --git a/pyo3-derive-backend/src/pymethod.rs b/pyo3-derive-backend/src/pymethod.rs index 4c102a21..0245ce4f 100644 --- a/pyo3-derive-backend/src/pymethod.rs +++ b/pyo3-derive-backend/src/pymethod.rs @@ -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"))); } } } diff --git a/src/class/basic.rs b/src/class/basic.rs index 29e19871..8c670bf8 100644 --- a/src/class/basic.rs +++ b/src/class/basic.rs @@ -202,7 +202,10 @@ trait GetAttrProtocolImpl { fn tp_getattro() -> Option; } -impl<'p, T> GetAttrProtocolImpl for T where T: PyObjectProtocol<'p> { +impl<'p, T> GetAttrProtocolImpl for T +where + T: PyObjectProtocol<'p>, +{ default fn tp_getattro() -> Option { None } @@ -296,7 +299,10 @@ mod tp_setattro_impl { fn del_attr() -> Option; } - impl<'p, T> DelAttr for T where T: PyObjectProtocol<'p> { + impl<'p, T> DelAttr for T + where + T: PyObjectProtocol<'p>, + { default fn del_attr() -> Option { None } @@ -315,7 +321,10 @@ mod tp_setattro_impl { fn set_del_attr() -> Option; } - impl<'p, T> SetDelAttr for T where T: PyObjectProtocol<'p> { + impl<'p, T> SetDelAttr for T + where + T: PyObjectProtocol<'p>, + { default fn set_del_attr() -> Option { None } @@ -340,7 +349,10 @@ mod tp_setattro_impl { trait StrProtocolImpl { fn tp_str() -> Option; } -impl<'p, T> StrProtocolImpl for T where T: PyObjectProtocol<'p> { +impl<'p, T> StrProtocolImpl for T +where + T: PyObjectProtocol<'p>, +{ default fn tp_str() -> Option { None } @@ -362,7 +374,10 @@ where trait ReprProtocolImpl { fn tp_repr() -> Option; } -impl<'p, T> ReprProtocolImpl for T where T: PyObjectProtocol<'p> { +impl<'p, T> ReprProtocolImpl for T +where + T: PyObjectProtocol<'p>, +{ default fn tp_repr() -> Option { None } @@ -385,7 +400,10 @@ where pub trait FormatProtocolImpl { fn __format__() -> Option; } -impl<'p, T> FormatProtocolImpl for T where T: PyObjectProtocol<'p> { +impl<'p, T> FormatProtocolImpl for T +where + T: PyObjectProtocol<'p>, +{ default fn __format__() -> Option { None } @@ -395,7 +413,10 @@ impl<'p, T> FormatProtocolImpl for T where T: PyObjectProtocol<'p> { pub trait BytesProtocolImpl { fn __bytes__() -> Option; } -impl<'p, T> BytesProtocolImpl for T where T: PyObjectProtocol<'p> { +impl<'p, T> BytesProtocolImpl for T +where + T: PyObjectProtocol<'p>, +{ default fn __bytes__() -> Option { None } @@ -405,7 +426,10 @@ impl<'p, T> BytesProtocolImpl for T where T: PyObjectProtocol<'p> { pub trait UnicodeProtocolImpl { fn __unicode__() -> Option; } -impl<'p, T> UnicodeProtocolImpl for T where T: PyObjectProtocol<'p> { +impl<'p, T> UnicodeProtocolImpl for T +where + T: PyObjectProtocol<'p>, +{ default fn __unicode__() -> Option { None } @@ -414,7 +438,10 @@ impl<'p, T> UnicodeProtocolImpl for T where T: PyObjectProtocol<'p> { trait HashProtocolImpl { fn tp_hash() -> Option; } -impl<'p, T> HashProtocolImpl for T where T: PyObjectProtocol<'p> { +impl<'p, T> HashProtocolImpl for T +where + T: PyObjectProtocol<'p>, +{ default fn tp_hash() -> Option { None } @@ -437,7 +464,10 @@ where trait BoolProtocolImpl { fn nb_bool() -> Option; } -impl<'p, T> BoolProtocolImpl for T where T: PyObjectProtocol<'p> { +impl<'p, T> BoolProtocolImpl for T +where + T: PyObjectProtocol<'p>, +{ default fn nb_bool() -> Option { None } @@ -460,7 +490,10 @@ where trait RichcmpProtocolImpl { fn tp_richcompare() -> Option; } -impl<'p, T> RichcmpProtocolImpl for T where T: PyObjectProtocol<'p> { +impl<'p, T> RichcmpProtocolImpl for T +where + T: PyObjectProtocol<'p>, +{ default fn tp_richcompare() -> Option { None } diff --git a/src/class/buffer.rs b/src/class/buffer.rs index c30f078c..f0f462db 100644 --- a/src/class/buffer.rs +++ b/src/class/buffer.rs @@ -69,7 +69,10 @@ trait PyBufferGetBufferProtocolImpl { fn cb_bf_getbuffer() -> Option; } -impl<'p, T> PyBufferGetBufferProtocolImpl for T where T: PyBufferProtocol<'p> { +impl<'p, T> PyBufferGetBufferProtocolImpl for T +where + T: PyBufferProtocol<'p>, +{ default fn cb_bf_getbuffer() -> Option { None } diff --git a/src/class/context.rs b/src/class/context.rs index 2ad59768..50aea33e 100644 --- a/src/class/context.rs +++ b/src/class/context.rs @@ -80,7 +80,10 @@ pub trait PyContextEnterProtocolImpl { fn __enter__() -> Option; } -impl<'p, T> PyContextEnterProtocolImpl for T where T: PyContextProtocol<'p> { +impl<'p, T> PyContextEnterProtocolImpl for T +where + T: PyContextProtocol<'p>, +{ default fn __enter__() -> Option { None } @@ -91,7 +94,10 @@ pub trait PyContextExitProtocolImpl { fn __exit__() -> Option; } -impl<'p, T> PyContextExitProtocolImpl for T where T: PyContextProtocol<'p> { +impl<'p, T> PyContextExitProtocolImpl for T +where + T: PyContextProtocol<'p>, +{ default fn __exit__() -> Option { None } diff --git a/src/class/descr.rs b/src/class/descr.rs index c7b5b966..57d9119c 100644 --- a/src/class/descr.rs +++ b/src/class/descr.rs @@ -72,7 +72,10 @@ pub trait PyDescrSetNameProtocol<'p>: PyDescrProtocol<'p> { trait PyDescrGetProtocolImpl { fn tp_descr_get() -> Option; } -impl<'p, T> PyDescrGetProtocolImpl for T where T: PyDescrProtocol<'p> { +impl<'p, T> PyDescrGetProtocolImpl for T +where + T: PyDescrProtocol<'p>, +{ default fn tp_descr_get() -> Option { None } @@ -95,7 +98,10 @@ where trait PyDescrSetProtocolImpl { fn tp_descr_set() -> Option; } -impl<'p, T> PyDescrSetProtocolImpl for T where T: PyDescrProtocol<'p> { +impl<'p, T> PyDescrSetProtocolImpl for T +where + T: PyDescrProtocol<'p>, +{ default fn tp_descr_set() -> Option { None } diff --git a/src/class/gc.rs b/src/class/gc.rs index 4b69c964..591b686a 100644 --- a/src/class/gc.rs +++ b/src/class/gc.rs @@ -68,7 +68,10 @@ trait PyGCTraverseProtocolImpl { fn tp_traverse() -> Option; } -impl<'p, T> PyGCTraverseProtocolImpl for T where T: PyGCProtocol<'p> { +impl<'p, T> PyGCTraverseProtocolImpl for T +where + T: PyGCProtocol<'p>, +{ default fn tp_traverse() -> Option { None } @@ -112,7 +115,10 @@ trait PyGCClearProtocolImpl { fn tp_clear() -> Option; } -impl<'p, T> PyGCClearProtocolImpl for T where T: PyGCProtocol<'p> { +impl<'p, T> PyGCClearProtocolImpl for T +where + T: PyGCProtocol<'p>, +{ default fn tp_clear() -> Option { None } diff --git a/src/class/iter.rs b/src/class/iter.rs index fcf76f2e..a528289d 100644 --- a/src/class/iter.rs +++ b/src/class/iter.rs @@ -66,7 +66,10 @@ trait PyIterIterProtocolImpl { fn tp_iter() -> Option; } -impl<'p, T> PyIterIterProtocolImpl for T where T: PyIterProtocol<'p> { +impl<'p, T> PyIterIterProtocolImpl for T +where + T: PyIterProtocol<'p>, +{ default fn tp_iter() -> Option { None } @@ -91,7 +94,10 @@ trait PyIterNextProtocolImpl { fn tp_iternext() -> Option; } -impl<'p, T> PyIterNextProtocolImpl for T where T: PyIterProtocol<'p> { +impl<'p, T> PyIterNextProtocolImpl for T +where + T: PyIterProtocol<'p>, +{ default fn tp_iternext() -> Option { None } diff --git a/src/class/mapping.rs b/src/class/mapping.rs index 64d7b57c..32326ff4 100644 --- a/src/class/mapping.rs +++ b/src/class/mapping.rs @@ -160,7 +160,10 @@ trait PyMappingLenProtocolImpl { fn mp_length() -> Option; } -impl<'p, T> PyMappingLenProtocolImpl for T where T: PyMappingProtocol<'p> { +impl<'p, T> PyMappingLenProtocolImpl for T +where + T: PyMappingProtocol<'p>, +{ default fn mp_length() -> Option { None } @@ -180,7 +183,10 @@ trait PyMappingGetItemProtocolImpl { fn mp_subscript() -> Option; } -impl<'p, T> PyMappingGetItemProtocolImpl for T where T: PyMappingProtocol<'p> { +impl<'p, T> PyMappingGetItemProtocolImpl for T +where + T: PyMappingProtocol<'p>, +{ default fn mp_subscript() -> Option { None } @@ -205,7 +211,10 @@ trait PyMappingSetItemProtocolImpl { fn mp_ass_subscript() -> Option; } -impl<'p, T> PyMappingSetItemProtocolImpl for T where T: PyMappingProtocol<'p> { +impl<'p, T> PyMappingSetItemProtocolImpl for T +where + T: PyMappingProtocol<'p>, +{ default fn mp_ass_subscript() -> Option { None } @@ -227,7 +236,10 @@ trait DeplItemDipatch { fn mp_del_subscript() -> Option; } -impl<'p, T> DeplItemDipatch for T where T: PyMappingProtocol<'p> { +impl<'p, T> DeplItemDipatch for T +where + T: PyMappingProtocol<'p>, +{ default fn mp_del_subscript() -> Option { None } @@ -238,7 +250,10 @@ trait DelSetItemDispatch: Sized + for<'p> PyMappingDelItemProtocol<'p> { fn det_set_dispatch() -> Option; } -impl DelSetItemDispatch for T where T: Sized + for<'p> PyMappingDelItemProtocol<'p> { +impl DelSetItemDispatch for T +where + T: Sized + for<'p> PyMappingDelItemProtocol<'p>, +{ default fn det_set_dispatch() -> Option { py_func_del!(PyMappingDelItemProtocol, Self, __delitem__) } @@ -273,7 +288,10 @@ pub trait PyMappingContainsProtocolImpl { fn __contains__() -> Option; } -impl<'p, T> PyMappingContainsProtocolImpl for T where T: PyMappingProtocol<'p> { +impl<'p, T> PyMappingContainsProtocolImpl for T +where + T: PyMappingProtocol<'p>, +{ default fn __contains__() -> Option { None } @@ -284,7 +302,10 @@ pub trait PyMappingReversedProtocolImpl { fn __reversed__() -> Option; } -impl<'p, T> PyMappingReversedProtocolImpl for T where T: PyMappingProtocol<'p> { +impl<'p, T> PyMappingReversedProtocolImpl for T +where + T: PyMappingProtocol<'p>, +{ default fn __reversed__() -> Option { None } @@ -295,7 +316,10 @@ pub trait PyMappingIterProtocolImpl { fn __iter__() -> Option; } -impl<'p, T> PyMappingIterProtocolImpl for T where T: PyMappingProtocol<'p> { +impl<'p, T> PyMappingIterProtocolImpl for T +where + T: PyMappingProtocol<'p>, +{ default fn __iter__() -> Option { None } diff --git a/src/class/number.rs b/src/class/number.rs index 0ab162e7..796b8bad 100644 --- a/src/class/number.rs +++ b/src/class/number.rs @@ -749,7 +749,10 @@ trait PyNumberAddProtocolImpl { fn nb_add() -> Option; } -impl<'p, T> PyNumberAddProtocolImpl for T where T: PyNumberProtocol<'p> { +impl<'p, T> PyNumberAddProtocolImpl for T +where + T: PyNumberProtocol<'p>, +{ default fn nb_add() -> Option { None } @@ -773,7 +776,10 @@ trait PyNumberSubProtocolImpl { fn nb_subtract() -> Option; } -impl<'p, T> PyNumberSubProtocolImpl for T where T: PyNumberProtocol<'p> { +impl<'p, T> PyNumberSubProtocolImpl for T +where + T: PyNumberProtocol<'p>, +{ default fn nb_subtract() -> Option { None } @@ -797,7 +803,10 @@ trait PyNumberMulProtocolImpl { fn nb_multiply() -> Option; } -impl<'p, T> PyNumberMulProtocolImpl for T where T: PyNumberProtocol<'p> { +impl<'p, T> PyNumberMulProtocolImpl for T +where + T: PyNumberProtocol<'p>, +{ default fn nb_multiply() -> Option { None } @@ -821,7 +830,10 @@ trait PyNumberMatmulProtocolImpl { fn nb_matrix_multiply() -> Option; } -impl<'p, T> PyNumberMatmulProtocolImpl for T where T: PyNumberProtocol<'p> { +impl<'p, T> PyNumberMatmulProtocolImpl for T +where + T: PyNumberProtocol<'p>, +{ default fn nb_matrix_multiply() -> Option { None } @@ -845,7 +857,10 @@ trait PyNumberTruedivProtocolImpl { fn nb_true_divide() -> Option; } -impl<'p, T> PyNumberTruedivProtocolImpl for T where T: PyNumberProtocol<'p> { +impl<'p, T> PyNumberTruedivProtocolImpl for T +where + T: PyNumberProtocol<'p>, +{ default fn nb_true_divide() -> Option { None } @@ -869,7 +884,10 @@ trait PyNumberFloordivProtocolImpl { fn nb_floor_divide() -> Option; } -impl<'p, T> PyNumberFloordivProtocolImpl for T where T: PyNumberProtocol<'p> { +impl<'p, T> PyNumberFloordivProtocolImpl for T +where + T: PyNumberProtocol<'p>, +{ default fn nb_floor_divide() -> Option { None } @@ -893,7 +911,10 @@ trait PyNumberModProtocolImpl { fn nb_remainder() -> Option; } -impl<'p, T> PyNumberModProtocolImpl for T where T: PyNumberProtocol<'p> { +impl<'p, T> PyNumberModProtocolImpl for T +where + T: PyNumberProtocol<'p>, +{ default fn nb_remainder() -> Option { None } @@ -917,7 +938,10 @@ trait PyNumberDivmodProtocolImpl { fn nb_divmod() -> Option; } -impl<'p, T> PyNumberDivmodProtocolImpl for T where T: PyNumberProtocol<'p> { +impl<'p, T> PyNumberDivmodProtocolImpl for T +where + T: PyNumberProtocol<'p>, +{ default fn nb_divmod() -> Option { None } @@ -941,7 +965,10 @@ trait PyNumberPowProtocolImpl { fn nb_power() -> Option; } -impl<'p, T> PyNumberPowProtocolImpl for T where T: PyNumberProtocol<'p> { +impl<'p, T> PyNumberPowProtocolImpl for T +where + T: PyNumberProtocol<'p>, +{ default fn nb_power() -> Option { None } @@ -965,7 +992,10 @@ trait PyNumberLShiftProtocolImpl { fn nb_lshift() -> Option; } -impl<'p, T> PyNumberLShiftProtocolImpl for T where T: PyNumberProtocol<'p> { +impl<'p, T> PyNumberLShiftProtocolImpl for T +where + T: PyNumberProtocol<'p>, +{ default fn nb_lshift() -> Option { None } @@ -989,7 +1019,10 @@ trait PyNumberRShiftProtocolImpl { fn nb_rshift() -> Option; } -impl<'p, T> PyNumberRShiftProtocolImpl for T where T: PyNumberProtocol<'p> { +impl<'p, T> PyNumberRShiftProtocolImpl for T +where + T: PyNumberProtocol<'p>, +{ default fn nb_rshift() -> Option { None } @@ -1013,7 +1046,10 @@ trait PyNumberAndProtocolImpl { fn nb_and() -> Option; } -impl<'p, T> PyNumberAndProtocolImpl for T where T: PyNumberProtocol<'p> { +impl<'p, T> PyNumberAndProtocolImpl for T +where + T: PyNumberProtocol<'p>, +{ default fn nb_and() -> Option { None } @@ -1037,7 +1073,10 @@ trait PyNumberXorProtocolImpl { fn nb_xor() -> Option; } -impl<'p, T> PyNumberXorProtocolImpl for T where T: PyNumberProtocol<'p> { +impl<'p, T> PyNumberXorProtocolImpl for T +where + T: PyNumberProtocol<'p>, +{ default fn nb_xor() -> Option { None } @@ -1061,7 +1100,10 @@ trait PyNumberOrProtocolImpl { fn nb_or() -> Option; } -impl<'p, T> PyNumberOrProtocolImpl for T where T: PyNumberProtocol<'p> { +impl<'p, T> PyNumberOrProtocolImpl for T +where + T: PyNumberProtocol<'p>, +{ default fn nb_or() -> Option { None } @@ -1085,7 +1127,10 @@ trait PyNumberIAddProtocolImpl { fn nb_inplace_add() -> Option; } -impl<'p, T> PyNumberIAddProtocolImpl for T where T: PyNumberProtocol<'p> { +impl<'p, T> PyNumberIAddProtocolImpl for T +where + T: PyNumberProtocol<'p>, +{ default fn nb_inplace_add() -> Option { None } @@ -1104,7 +1149,10 @@ trait PyNumberISubProtocolImpl { fn nb_inplace_subtract() -> Option; } -impl<'p, T> PyNumberISubProtocolImpl for T where T: PyNumberProtocol<'p> { +impl<'p, T> PyNumberISubProtocolImpl for T +where + T: PyNumberProtocol<'p>, +{ default fn nb_inplace_subtract() -> Option { None } @@ -1123,7 +1171,10 @@ trait PyNumberIMulProtocolImpl { fn nb_inplace_multiply() -> Option; } -impl<'p, T> PyNumberIMulProtocolImpl for T where T: PyNumberProtocol<'p> { +impl<'p, T> PyNumberIMulProtocolImpl for T +where + T: PyNumberProtocol<'p>, +{ default fn nb_inplace_multiply() -> Option { None } @@ -1142,7 +1193,10 @@ trait PyNumberIMatmulProtocolImpl { fn nb_inplace_matrix_multiply() -> Option; } -impl<'p, T> PyNumberIMatmulProtocolImpl for T where T: PyNumberProtocol<'p> { +impl<'p, T> PyNumberIMatmulProtocolImpl for T +where + T: PyNumberProtocol<'p>, +{ default fn nb_inplace_matrix_multiply() -> Option { None } @@ -1161,7 +1215,10 @@ trait PyNumberITruedivProtocolImpl { fn nb_inplace_true_divide() -> Option; } -impl<'p, T> PyNumberITruedivProtocolImpl for T where T: PyNumberProtocol<'p> { +impl<'p, T> PyNumberITruedivProtocolImpl for T +where + T: PyNumberProtocol<'p>, +{ default fn nb_inplace_true_divide() -> Option { None } @@ -1180,7 +1237,10 @@ trait PyNumberIFloordivProtocolImpl { fn nb_inplace_floor_divide() -> Option; } -impl<'p, T> PyNumberIFloordivProtocolImpl for T where T: PyNumberProtocol<'p> { +impl<'p, T> PyNumberIFloordivProtocolImpl for T +where + T: PyNumberProtocol<'p>, +{ default fn nb_inplace_floor_divide() -> Option { None } @@ -1199,7 +1259,10 @@ trait PyNumberIModProtocolImpl { fn nb_inplace_remainder() -> Option; } -impl<'p, T> PyNumberIModProtocolImpl for T where T: PyNumberProtocol<'p> { +impl<'p, T> PyNumberIModProtocolImpl for T +where + T: PyNumberProtocol<'p>, +{ default fn nb_inplace_remainder() -> Option { None } @@ -1218,7 +1281,10 @@ trait PyNumberIPowProtocolImpl { fn nb_inplace_power() -> Option; } -impl<'p, T> PyNumberIPowProtocolImpl for T where T: PyNumberProtocol<'p> { +impl<'p, T> PyNumberIPowProtocolImpl for T +where + T: PyNumberProtocol<'p>, +{ default fn nb_inplace_power() -> Option { None } @@ -1237,7 +1303,10 @@ trait PyNumberILShiftProtocolImpl { fn nb_inplace_lshift() -> Option; } -impl<'p, T> PyNumberILShiftProtocolImpl for T where T: PyNumberProtocol<'p> { +impl<'p, T> PyNumberILShiftProtocolImpl for T +where + T: PyNumberProtocol<'p>, +{ default fn nb_inplace_lshift() -> Option { None } @@ -1256,7 +1325,10 @@ trait PyNumberIRShiftProtocolImpl { fn nb_inplace_rshift() -> Option; } -impl<'p, T> PyNumberIRShiftProtocolImpl for T where T: PyNumberProtocol<'p> { +impl<'p, T> PyNumberIRShiftProtocolImpl for T +where + T: PyNumberProtocol<'p>, +{ default fn nb_inplace_rshift() -> Option { None } @@ -1275,7 +1347,10 @@ trait PyNumberIAndProtocolImpl { fn nb_inplace_and() -> Option; } -impl<'p, T> PyNumberIAndProtocolImpl for T where T: PyNumberProtocol<'p> { +impl<'p, T> PyNumberIAndProtocolImpl for T +where + T: PyNumberProtocol<'p>, +{ default fn nb_inplace_and() -> Option { None } @@ -1294,7 +1369,10 @@ trait PyNumberIXorProtocolImpl { fn nb_inplace_xor() -> Option; } -impl<'p, T> PyNumberIXorProtocolImpl for T where T: PyNumberProtocol<'p> { +impl<'p, T> PyNumberIXorProtocolImpl for T +where + T: PyNumberProtocol<'p>, +{ default fn nb_inplace_xor() -> Option { None } @@ -1313,7 +1391,10 @@ trait PyNumberIOrProtocolImpl { fn nb_inplace_or() -> Option; } -impl<'p, T> PyNumberIOrProtocolImpl for T where T: PyNumberProtocol<'p> { +impl<'p, T> PyNumberIOrProtocolImpl for T +where + T: PyNumberProtocol<'p>, +{ default fn nb_inplace_or() -> Option { None } @@ -1333,7 +1414,10 @@ pub trait PyNumberRAddProtocolImpl { fn __radd__() -> Option; } -impl<'p, T> PyNumberRAddProtocolImpl for T where T: PyNumberProtocol<'p> { +impl<'p, T> PyNumberRAddProtocolImpl for T +where + T: PyNumberProtocol<'p>, +{ default fn __radd__() -> Option { None } @@ -1353,7 +1437,10 @@ pub trait PyNumberRMulProtocolImpl { fn __rmul__() -> Option; } -impl<'p, T> PyNumberRMulProtocolImpl for T where T: PyNumberProtocol<'p> { +impl<'p, T> PyNumberRMulProtocolImpl for T +where + T: PyNumberProtocol<'p>, +{ default fn __rmul__() -> Option { None } @@ -1364,7 +1451,10 @@ pub trait PyNumberRMatmulProtocolImpl { fn __rmatmul__() -> Option; } -impl<'p, T> PyNumberRMatmulProtocolImpl for T where T: PyNumberProtocol<'p> { +impl<'p, T> PyNumberRMatmulProtocolImpl for T +where + T: PyNumberProtocol<'p>, +{ default fn __rmatmul__() -> Option { None } @@ -1375,7 +1465,10 @@ pub trait PyNumberRTruedivProtocolImpl { fn __rtruediv__() -> Option; } -impl<'p, T> PyNumberRTruedivProtocolImpl for T where T: PyNumberProtocol<'p> { +impl<'p, T> PyNumberRTruedivProtocolImpl for T +where + T: PyNumberProtocol<'p>, +{ default fn __rtruediv__() -> Option { None } @@ -1386,7 +1479,10 @@ pub trait PyNumberRFloordivProtocolImpl { fn __rfloordiv__() -> Option; } -impl<'p, T> PyNumberRFloordivProtocolImpl for T where T: PyNumberProtocol<'p> { +impl<'p, T> PyNumberRFloordivProtocolImpl for T +where + T: PyNumberProtocol<'p>, +{ default fn __rfloordiv__() -> Option { None } @@ -1397,7 +1493,10 @@ pub trait PyNumberRModProtocolImpl { fn __rmod__() -> Option; } -impl<'p, T> PyNumberRModProtocolImpl for T where T: PyNumberProtocol<'p> { +impl<'p, T> PyNumberRModProtocolImpl for T +where + T: PyNumberProtocol<'p>, +{ default fn __rmod__() -> Option { None } @@ -1408,7 +1507,10 @@ pub trait PyNumberRDivmodProtocolImpl { fn __rdivmod__() -> Option; } -impl<'p, T> PyNumberRDivmodProtocolImpl for T where T: PyNumberProtocol<'p> { +impl<'p, T> PyNumberRDivmodProtocolImpl for T +where + T: PyNumberProtocol<'p>, +{ default fn __rdivmod__() -> Option { None } @@ -1419,7 +1521,10 @@ pub trait PyNumberRPowProtocolImpl { fn __rpow__() -> Option; } -impl<'p, T> PyNumberRPowProtocolImpl for T where T: PyNumberProtocol<'p> { +impl<'p, T> PyNumberRPowProtocolImpl for T +where + T: PyNumberProtocol<'p>, +{ default fn __rpow__() -> Option { None } @@ -1430,7 +1535,10 @@ pub trait PyNumberRLShiftProtocolImpl { fn __rlshift__() -> Option; } -impl<'p, T> PyNumberRLShiftProtocolImpl for T where T: PyNumberProtocol<'p> { +impl<'p, T> PyNumberRLShiftProtocolImpl for T +where + T: PyNumberProtocol<'p>, +{ default fn __rlshift__() -> Option { None } @@ -1441,7 +1549,10 @@ pub trait PyNumberRRShiftProtocolImpl { fn __rrshift__() -> Option; } -impl<'p, T> PyNumberRRShiftProtocolImpl for T where T: PyNumberProtocol<'p> { +impl<'p, T> PyNumberRRShiftProtocolImpl for T +where + T: PyNumberProtocol<'p>, +{ default fn __rrshift__() -> Option { None } @@ -1452,7 +1563,10 @@ pub trait PyNumberRAndProtocolImpl { fn __rand__() -> Option; } -impl<'p, T> PyNumberRAndProtocolImpl for T where T: PyNumberProtocol<'p> { +impl<'p, T> PyNumberRAndProtocolImpl for T +where + T: PyNumberProtocol<'p>, +{ default fn __rand__() -> Option { None } @@ -1463,7 +1577,10 @@ pub trait PyNumberRXorProtocolImpl { fn __rxor__() -> Option; } -impl<'p, T> PyNumberRXorProtocolImpl for T where T: PyNumberProtocol<'p> { +impl<'p, T> PyNumberRXorProtocolImpl for T +where + T: PyNumberProtocol<'p>, +{ default fn __rxor__() -> Option { None } @@ -1474,7 +1591,10 @@ pub trait PyNumberROrProtocolImpl { fn __ror__() -> Option; } -impl<'p, T> PyNumberROrProtocolImpl for T where T: PyNumberProtocol<'p> { +impl<'p, T> PyNumberROrProtocolImpl for T +where + T: PyNumberProtocol<'p>, +{ default fn __ror__() -> Option { None } @@ -1484,7 +1604,10 @@ trait PyNumberNegProtocolImpl { fn nb_negative() -> Option; } -impl<'p, T> PyNumberNegProtocolImpl for T where T: PyNumberProtocol<'p> { +impl<'p, T> PyNumberNegProtocolImpl for T +where + T: PyNumberProtocol<'p>, +{ default fn nb_negative() -> Option { None } @@ -1509,7 +1632,10 @@ trait PyNumberPosProtocolImpl { fn nb_positive() -> Option; } -impl<'p, T> PyNumberPosProtocolImpl for T where T: PyNumberProtocol<'p> { +impl<'p, T> PyNumberPosProtocolImpl for T +where + T: PyNumberProtocol<'p>, +{ default fn nb_positive() -> Option { None } @@ -1533,7 +1659,10 @@ trait PyNumberAbsProtocolImpl { fn nb_absolute() -> Option; } -impl<'p, T> PyNumberAbsProtocolImpl for T where T: PyNumberProtocol<'p> { +impl<'p, T> PyNumberAbsProtocolImpl for T +where + T: PyNumberProtocol<'p>, +{ default fn nb_absolute() -> Option { None } @@ -1557,7 +1686,10 @@ trait PyNumberInvertProtocolImpl { fn nb_invert() -> Option; } -impl<'p, T> PyNumberInvertProtocolImpl for T where T: PyNumberProtocol<'p> { +impl<'p, T> PyNumberInvertProtocolImpl for T +where + T: PyNumberProtocol<'p>, +{ default fn nb_invert() -> Option { None } @@ -1581,7 +1713,10 @@ trait PyNumberIntProtocolImpl { fn nb_int() -> Option; } -impl<'p, T> PyNumberIntProtocolImpl for T where T: PyNumberProtocol<'p> { +impl<'p, T> PyNumberIntProtocolImpl for T +where + T: PyNumberProtocol<'p>, +{ default fn nb_int() -> Option { None } @@ -1605,7 +1740,10 @@ trait PyNumberFloatProtocolImpl { fn nb_float() -> Option; } -impl<'p, T> PyNumberFloatProtocolImpl for T where T: PyNumberProtocol<'p> { +impl<'p, T> PyNumberFloatProtocolImpl for T +where + T: PyNumberProtocol<'p>, +{ default fn nb_float() -> Option { None } @@ -1629,7 +1767,10 @@ trait PyNumberIndexProtocolImpl { fn nb_index() -> Option; } -impl<'p, T> PyNumberIndexProtocolImpl for T where T: PyNumberProtocol<'p> { +impl<'p, T> PyNumberIndexProtocolImpl for T +where + T: PyNumberProtocol<'p>, +{ default fn nb_index() -> Option { None } @@ -1653,7 +1794,10 @@ trait PyNumberComplexProtocolImpl { fn __complex__() -> Option; } -impl<'p, T> PyNumberComplexProtocolImpl for T where T: PyNumberProtocol<'p> { +impl<'p, T> PyNumberComplexProtocolImpl for T +where + T: PyNumberProtocol<'p>, +{ default fn __complex__() -> Option { None } @@ -1663,7 +1807,10 @@ trait PyNumberRoundProtocolImpl { fn __round__() -> Option; } -impl<'p, T> PyNumberRoundProtocolImpl for T where T: PyNumberProtocol<'p> { +impl<'p, T> PyNumberRoundProtocolImpl for T +where + T: PyNumberProtocol<'p>, +{ default fn __round__() -> Option { None } diff --git a/src/class/pyasync.rs b/src/class/pyasync.rs index f977fadf..2536d4ce 100644 --- a/src/class/pyasync.rs +++ b/src/class/pyasync.rs @@ -137,7 +137,10 @@ trait PyAsyncAwaitProtocolImpl { fn am_await() -> Option; } -impl<'p, T> PyAsyncAwaitProtocolImpl for T where T: PyAsyncProtocol<'p> { +impl<'p, T> PyAsyncAwaitProtocolImpl for T +where + T: PyAsyncProtocol<'p>, +{ default fn am_await() -> Option { None } @@ -162,7 +165,10 @@ trait PyAsyncAiterProtocolImpl { fn am_aiter() -> Option; } -impl<'p, T> PyAsyncAiterProtocolImpl for T where T: PyAsyncProtocol<'p> { +impl<'p, T> PyAsyncAiterProtocolImpl for T +where + T: PyAsyncProtocol<'p>, +{ default fn am_aiter() -> Option { None } @@ -187,7 +193,10 @@ trait PyAsyncAnextProtocolImpl { fn am_anext() -> Option; } -impl<'p, T> PyAsyncAnextProtocolImpl for T where T: PyAsyncProtocol<'p> { +impl<'p, T> PyAsyncAnextProtocolImpl for T +where + T: PyAsyncProtocol<'p>, +{ default fn am_anext() -> Option { None } @@ -245,7 +254,10 @@ trait PyAsyncAenterProtocolImpl { fn __aenter__() -> Option; } -impl<'p, T> PyAsyncAenterProtocolImpl for T where T: PyAsyncProtocol<'p> { +impl<'p, T> PyAsyncAenterProtocolImpl for T +where + T: PyAsyncProtocol<'p>, +{ default fn __aenter__() -> Option { None } @@ -255,7 +267,10 @@ trait PyAsyncAexitProtocolImpl { fn __aexit__() -> Option; } -impl<'p, T> PyAsyncAexitProtocolImpl for T where T: PyAsyncProtocol<'p> { +impl<'p, T> PyAsyncAexitProtocolImpl for T +where + T: PyAsyncProtocol<'p>, +{ default fn __aexit__() -> Option { None } diff --git a/src/class/sequence.rs b/src/class/sequence.rs index 082323b6..0f9ca44b 100644 --- a/src/class/sequence.rs +++ b/src/class/sequence.rs @@ -167,7 +167,10 @@ trait PySequenceLenProtocolImpl { fn sq_length() -> Option; } -impl<'p, T> PySequenceLenProtocolImpl for T where T: PySequenceProtocol<'p> { +impl<'p, T> PySequenceLenProtocolImpl for T +where + T: PySequenceProtocol<'p>, +{ default fn sq_length() -> Option { None } @@ -186,7 +189,10 @@ trait PySequenceGetItemProtocolImpl { fn sq_item() -> Option; } -impl<'p, T> PySequenceGetItemProtocolImpl for T where T: PySequenceProtocol<'p> { +impl<'p, T> PySequenceGetItemProtocolImpl for T +where + T: PySequenceProtocol<'p>, +{ default fn sq_item() -> Option { None } @@ -210,7 +216,10 @@ trait PySequenceSetItemProtocolImpl { fn sq_ass_item() -> Option; } -impl<'p, T> PySequenceSetItemProtocolImpl for T where T: PySequenceProtocol<'p> { +impl<'p, T> PySequenceSetItemProtocolImpl for T +where + T: PySequenceProtocol<'p>, +{ default fn sq_ass_item() -> Option { None } @@ -286,7 +295,10 @@ mod sq_ass_item_impl { fn del_item() -> Option; } - impl<'p, T> DelItem for T where T: PySequenceProtocol<'p> { + impl<'p, T> DelItem for T + where + T: PySequenceProtocol<'p>, + { default fn del_item() -> Option { None } @@ -334,7 +346,10 @@ mod sq_ass_item_impl { fn del_set_item() -> Option; } - impl<'p, T> DelSetItem for T where T: PySequenceProtocol<'p> { + impl<'p, T> DelSetItem for T + where + T: PySequenceProtocol<'p>, + { default fn del_set_item() -> Option { None } @@ -383,7 +398,10 @@ trait PySequenceContainsProtocolImpl { fn sq_contains() -> Option; } -impl<'p, T> PySequenceContainsProtocolImpl for T where T: PySequenceProtocol<'p> { +impl<'p, T> PySequenceContainsProtocolImpl for T +where + T: PySequenceProtocol<'p>, +{ default fn sq_contains() -> Option { None } @@ -408,7 +426,10 @@ trait PySequenceConcatProtocolImpl { fn sq_concat() -> Option; } -impl<'p, T> PySequenceConcatProtocolImpl for T where T: PySequenceProtocol<'p> { +impl<'p, T> PySequenceConcatProtocolImpl for T +where + T: PySequenceProtocol<'p>, +{ default fn sq_concat() -> Option { None } @@ -432,7 +453,10 @@ trait PySequenceRepeatProtocolImpl { fn sq_repeat() -> Option; } -impl<'p, T> PySequenceRepeatProtocolImpl for T where T: PySequenceProtocol<'p> { +impl<'p, T> PySequenceRepeatProtocolImpl for T +where + T: PySequenceProtocol<'p>, +{ default fn sq_repeat() -> Option { None } @@ -456,7 +480,10 @@ trait PySequenceInplaceConcatProtocolImpl { fn sq_inplace_concat() -> Option; } -impl<'p, T> PySequenceInplaceConcatProtocolImpl for T where T: PySequenceProtocol<'p> { +impl<'p, T> PySequenceInplaceConcatProtocolImpl for T +where + T: PySequenceProtocol<'p>, +{ default fn sq_inplace_concat() -> Option { None } @@ -480,7 +507,10 @@ trait PySequenceInplaceRepeatProtocolImpl { fn sq_inplace_repeat() -> Option; } -impl<'p, T> PySequenceInplaceRepeatProtocolImpl for T where T: PySequenceProtocol<'p> { +impl<'p, T> PySequenceInplaceRepeatProtocolImpl for T +where + T: PySequenceProtocol<'p>, +{ default fn sq_inplace_repeat() -> Option { None } diff --git a/src/conversion.rs b/src/conversion.rs index 15ccdabd..38f436de 100644 --- a/src/conversion.rs +++ b/src/conversion.rs @@ -100,7 +100,10 @@ pub trait ToBorrowedObject: ToPyObject { F: FnOnce(*mut ffi::PyObject) -> R; } -impl ToBorrowedObject for T where T: ToPyObject { +impl ToBorrowedObject for T +where + T: ToPyObject, +{ default fn with_borrowed_ptr(&self, py: Python, f: F) -> R where F: FnOnce(*mut ffi::PyObject) -> R,