From cf329549bad27b5f9f04784f86c4190c0de3a9ad Mon Sep 17 00:00:00 2001 From: Icxolu <10486322+Icxolu@users.noreply.github.com> Date: Tue, 27 Feb 2024 23:58:03 +0100 Subject: [PATCH] move `PyResultExt` seal --- src/py_result_ext.rs | 12 +----------- src/sealed.rs | 5 ++++- 2 files changed, 5 insertions(+), 12 deletions(-) diff --git a/src/py_result_ext.rs b/src/py_result_ext.rs index 66309988dc4..2ad079ed7ac 100644 --- a/src/py_result_ext.rs +++ b/src/py_result_ext.rs @@ -1,16 +1,6 @@ use crate::{types::any::PyAnyMethods, Bound, PyAny, PyResult, PyTypeCheck}; -mod sealed { - use super::*; - - pub trait Sealed {} - - impl Sealed for PyResult> {} -} - -use sealed::Sealed; - -pub(crate) trait PyResultExt<'py>: Sealed { +pub(crate) trait PyResultExt<'py>: crate::sealed::Sealed { fn downcast_into(self) -> PyResult>; unsafe fn downcast_into_unchecked(self) -> PyResult>; } diff --git a/src/sealed.rs b/src/sealed.rs index 691af5248f5..e2d5c5ccfed 100644 --- a/src/sealed.rs +++ b/src/sealed.rs @@ -2,13 +2,16 @@ use crate::types::{ PyBool, PyByteArray, PyBytes, PyCapsule, PyComplex, PyDict, PyFloat, PyFrozenSet, PyList, PyMapping, PyModule, PySequence, PySet, PySlice, PyString, PyTraceback, PyTuple, PyType, }; -use crate::{ffi, Bound, PyAny}; +use crate::{ffi, Bound, PyAny, PyResult}; pub trait Sealed {} // for FfiPtrExt impl Sealed for *mut ffi::PyObject {} +// for PyResultExt +impl Sealed for PyResult> {} + // for Py(...)Methods impl Sealed for Bound<'_, PyAny> {} impl Sealed for Bound<'_, PyBool> {}