Move From<&T> for Py<T> impl to pyobject_native_type_core
This commit is contained in:
parent
cb90c5171d
commit
f45242f053
|
@ -72,15 +72,6 @@ macro_rules! pyobject_native_type_named (
|
||||||
unsafe { $crate::Py::from_borrowed_ptr(py, self.as_ptr()) }
|
unsafe { $crate::Py::from_borrowed_ptr(py, self.as_ptr()) }
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
impl<$($type_param,)*> From<&'_ $name> for $crate::Py<$name> {
|
|
||||||
#[inline]
|
|
||||||
fn from(other: &$name) -> Self {
|
|
||||||
use $crate::AsPyPointer;
|
|
||||||
use $crate::PyNativeType;
|
|
||||||
unsafe { $crate::Py::from_borrowed_ptr(other.py(), other.as_ptr()) }
|
|
||||||
}
|
|
||||||
}
|
|
||||||
};
|
};
|
||||||
);
|
);
|
||||||
|
|
||||||
|
@ -97,6 +88,18 @@ macro_rules! pyobject_native_type_core {
|
||||||
unsafe{&*(ob as *const $name as *const $crate::PyAny)}
|
unsafe{&*(ob as *const $name as *const $crate::PyAny)}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
// TODO: Rust>=1.40 allows this impl for rust-numpy.
|
||||||
|
// So we should move this to `named` or `convert` when we bump MSRV.
|
||||||
|
impl<$($type_param,)*> From<&'_ $name> for $crate::Py<$name> {
|
||||||
|
#[inline]
|
||||||
|
fn from(other: &$name) -> Self {
|
||||||
|
use $crate::AsPyPointer;
|
||||||
|
use $crate::PyNativeType;
|
||||||
|
unsafe { $crate::Py::from_borrowed_ptr(other.py(), other.as_ptr()) }
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue