Skip to content

Commit

Permalink
merge Extractors
Browse files Browse the repository at this point in the history
  • Loading branch information
Icxolu committed Mar 12, 2024
1 parent 5c3a4de commit 0aef14b
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 37 deletions.
37 changes: 0 additions & 37 deletions src/impl_/pyfunction.rs
Original file line number Diff line number Diff line change
Expand Up @@ -67,40 +67,3 @@ impl<'py> WrapPyFunctionArg<'py, Bound<'py, PyCFunction>> for OnlyBound<Python<'
PyCFunction::internal_new(self.0, method_def, None)
}
}

pub fn inspect_type<T>(t: T) -> (T, Extractor<T>) {
(t, Extractor::new())
}

pub struct Extractor<T>(NotPython<T>);
pub struct NotPython<T>(std::marker::PhantomData<T>);

pub trait IsPython {}

impl IsPython for Python<'_> {}

impl<T> Extractor<T> {
#[allow(clippy::new_without_default)]
pub fn new() -> Self {
Extractor(NotPython(std::marker::PhantomData))
}
}

impl<T: IsPython> Extractor<T> {
#[cfg_attr(
not(feature = "gil-refs"),
deprecated(since = "0.21.0", note = "use `wrap_pyfunction_bound!` instead")
)]
pub fn is_python(&self) {}
}

impl<T> NotPython<T> {
pub fn is_python(&self) {}
}

impl<T> std::ops::Deref for Extractor<T> {
type Target = NotPython<T>;
fn deref(&self) -> &Self::Target {
&self.0
}
}
9 changes: 9 additions & 0 deletions src/impl_/pymethods.rs
Original file line number Diff line number Diff line change
Expand Up @@ -599,6 +599,14 @@ impl<T> Extractor<T> {
}
}

impl Extractor<Python<'_>> {
#[cfg_attr(
not(feature = "gil-refs"),
deprecated(since = "0.21.0", note = "use `wrap_pyfunction_bound!` instead")
)]
pub fn is_python(&self) {}
}

impl<T: IsGilRef> Extractor<T> {
#[cfg_attr(
not(feature = "gil-refs"),
Expand All @@ -612,6 +620,7 @@ impl<T: IsGilRef> Extractor<T> {

impl<T> NotAGilRef<T> {
pub fn extract_gil_ref(&self) {}
pub fn is_python(&self) {}
}

impl<T> std::ops::Deref for Extractor<T> {
Expand Down

0 comments on commit 0aef14b

Please sign in to comment.