Skip to content

Commit

Permalink
seal PyWeakrefMethods (#4598)
Browse files Browse the repository at this point in the history
* seal `PyWeakrefMethods`

* newsfragment
  • Loading branch information
davidhewitt authored Oct 4, 2024
1 parent 58c5c3a commit 0c4bf1e
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 1 deletion.
1 change: 1 addition & 0 deletions newsfragments/4598.changed.md
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
Seal `PyWeakrefMethods` trait.
4 changes: 4 additions & 0 deletions src/sealed.rs
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
use crate::types::{
PyBool, PyByteArray, PyBytes, PyCapsule, PyComplex, PyDict, PyFloat, PyFrozenSet, PyList,
PyMapping, PyModule, PySequence, PySet, PySlice, PyString, PyTraceback, PyTuple, PyType,
PyWeakref, PyWeakrefProxy, PyWeakrefReference,
};
use crate::{ffi, Bound, PyAny, PyResult};

Expand Down Expand Up @@ -32,3 +33,6 @@ impl Sealed for Bound<'_, PyString> {}
impl Sealed for Bound<'_, PyTraceback> {}
impl Sealed for Bound<'_, PyTuple> {}
impl Sealed for Bound<'_, PyType> {}
impl Sealed for Bound<'_, PyWeakref> {}
impl Sealed for Bound<'_, PyWeakrefProxy> {}
impl Sealed for Bound<'_, PyWeakrefReference> {}
2 changes: 1 addition & 1 deletion src/types/weakref/anyref.rs
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ impl PyTypeCheck for PyWeakref {
/// syntax these methods are separated into a trait, because stable Rust does not yet support
/// `arbitrary_self_types`.
#[doc(alias = "PyWeakref")]
pub trait PyWeakrefMethods<'py> {
pub trait PyWeakrefMethods<'py>: crate::sealed::Sealed {
/// Upgrade the weakref to a direct Bound object reference.
///
/// It is named `upgrade` to be inline with [rust's `Weak::upgrade`](std::rc::Weak::upgrade).
Expand Down

0 comments on commit 0c4bf1e

Please sign in to comment.