11#![ cfg( feature = "num-complex" ) ]
2- #! [ cfg_attr ( docsrs , doc ( cfg ( feature = "num-complex" ) ) ) ]
2+
33//! Conversions to and from [num-complex](https://docs.rs/num-complex)’
44//! [`Complex`]`<`[`f32`]`>` and [`Complex`]`<`[`f64`]`>`.
55//!
@@ -117,12 +117,15 @@ impl PyComplex {
117117
118118macro_rules! complex_conversion {
119119 ( $float: ty) => {
120+ #[ cfg_attr( docsrs, doc( cfg( feature = "num-complex" ) ) ) ]
120121 impl ToPyObject for Complex <$float> {
121122 #[ inline]
122123 fn to_object( & self , py: Python ) -> PyObject {
123124 crate :: IntoPy :: <PyObject >:: into_py( self . to_owned( ) , py)
124125 }
125126 }
127+
128+ #[ cfg_attr( docsrs, doc( cfg( feature = "num-complex" ) ) ) ]
126129 impl crate :: IntoPy <PyObject > for Complex <$float> {
127130 fn into_py( self , py: Python ) -> PyObject {
128131 unsafe {
@@ -132,10 +135,12 @@ macro_rules! complex_conversion {
132135 }
133136 }
134137 }
135- #[ cfg( not( any( Py_LIMITED_API , PyPy ) ) ) ]
138+
139+ #[ cfg_attr( docsrs, doc( cfg( feature = "num-complex" ) ) ) ]
136140 #[ allow( clippy:: float_cmp) ] // The comparison is for an error value
137141 impl <' source> FromPyObject <' source> for Complex <$float> {
138142 fn extract( obj: & ' source PyAny ) -> PyResult <Complex <$float>> {
143+ #[ cfg( not( any( Py_LIMITED_API , PyPy ) ) ) ]
139144 unsafe {
140145 let val = ffi:: PyComplex_AsCComplex ( obj. as_ptr( ) ) ;
141146 if val. real == -1.0 && PyErr :: occurred( obj. py( ) ) {
@@ -144,12 +149,8 @@ macro_rules! complex_conversion {
144149 Ok ( Complex :: new( val. real as $float, val. imag as $float) )
145150 }
146151 }
147- }
148- }
149- #[ cfg( any( Py_LIMITED_API , PyPy ) ) ]
150- #[ allow( clippy:: float_cmp) ] // The comparison is for an error value
151- impl <' source> FromPyObject <' source> for Complex <$float> {
152- fn extract( obj: & ' source PyAny ) -> PyResult <Complex <$float>> {
152+
153+ #[ cfg( any( Py_LIMITED_API , PyPy ) ) ]
153154 unsafe {
154155 let ptr = obj. as_ptr( ) ;
155156 let real = ffi:: PyComplex_RealAsDouble ( ptr) ;
0 commit comments