Skip to content

Commit

Permalink
move PyResultExt seal
Browse files Browse the repository at this point in the history
  • Loading branch information
Icxolu committed Feb 27, 2024
1 parent 3e88ae7 commit cf32954
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 12 deletions.
12 changes: 1 addition & 11 deletions src/py_result_ext.rs
Original file line number Diff line number Diff line change
@@ -1,16 +1,6 @@
use crate::{types::any::PyAnyMethods, Bound, PyAny, PyResult, PyTypeCheck};

mod sealed {
use super::*;

pub trait Sealed {}

impl Sealed for PyResult<Bound<'_, PyAny>> {}
}

use sealed::Sealed;

pub(crate) trait PyResultExt<'py>: Sealed {
pub(crate) trait PyResultExt<'py>: crate::sealed::Sealed {
fn downcast_into<T: PyTypeCheck>(self) -> PyResult<Bound<'py, T>>;
unsafe fn downcast_into_unchecked<T>(self) -> PyResult<Bound<'py, T>>;
}
Expand Down
5 changes: 4 additions & 1 deletion src/sealed.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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<Bound<'_, PyAny>> {}

// for Py(...)Methods
impl Sealed for Bound<'_, PyAny> {}
impl Sealed for Bound<'_, PyBool> {}
Expand Down

0 comments on commit cf32954

Please sign in to comment.