Merge pull request #1228 from PyO3/exclude-py-coversion

Move impl From for Py<T> to macros not used in rust-numpy
This commit is contained in:
David Hewitt 2020-10-12 09:00:57 +01:00 committed by GitHub
commit 1749747ad4
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 12 additions and 9 deletions

View File

@ -72,15 +72,6 @@ macro_rules! pyobject_native_type_named (
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)}
}
}
// 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()) }
}
}
}
}