PyAny::downcast(): relax lifetime bounds
This commit is contained in:
parent
c489809938
commit
7d4dfc32b3
|
@ -1,2 +1,3 @@
|
|||
`PyAny::cast_as()` and `Py::cast_as()` are now deprecated in favor of
|
||||
`PyAny::downcast()` and the new `Py::downcast()`.
|
||||
`PyAny::downcast()` and the new `Py::downcast()`. The `PyAny::downcast()`
|
||||
lifetime bounds where slightly relaxed.
|
||||
|
|
|
@ -997,7 +997,7 @@ impl PyObject {
|
|||
/// flexible alternative, see [`Py::extract`](struct.Py.html#method.extract).
|
||||
pub fn downcast<'p, T>(&'p self, py: Python<'p>) -> Result<&T, PyDowncastError<'_>>
|
||||
where
|
||||
for<'py> T: PyTryFrom<'py>,
|
||||
T: PyTryFrom<'p>,
|
||||
{
|
||||
<T as PyTryFrom<'_>>::try_from(self.as_ref(py))
|
||||
}
|
||||
|
@ -1008,7 +1008,7 @@ impl PyObject {
|
|||
where
|
||||
D: PyTryFrom<'p>,
|
||||
{
|
||||
<D as PyTryFrom<'_>>::try_from(self.as_ref(py))
|
||||
self.downcast(py)
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -752,7 +752,7 @@ impl PyAny {
|
|||
where
|
||||
D: PyTryFrom<'a>,
|
||||
{
|
||||
<D as PyTryFrom<'_>>::try_from(self)
|
||||
self.downcast()
|
||||
}
|
||||
|
||||
/// Converts this `PyAny` to a concrete Python type.
|
||||
|
@ -773,9 +773,9 @@ impl PyAny {
|
|||
/// assert!(any.downcast::<PyList>().is_err());
|
||||
/// });
|
||||
/// ```
|
||||
pub fn downcast<T>(&self) -> Result<&T, PyDowncastError<'_>>
|
||||
pub fn downcast<'p, T>(&'p self) -> Result<&'p T, PyDowncastError<'_>>
|
||||
where
|
||||
for<'py> T: PyTryFrom<'py>,
|
||||
T: PyTryFrom<'p>,
|
||||
{
|
||||
<T as PyTryFrom>::try_from(self)
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue