Skip to content

Commit

Permalink
update docs to reference PyWeakref_GetRef semantics
Browse files Browse the repository at this point in the history
  • Loading branch information
ngoldbaum committed Sep 5, 2024
1 parent c26f3b3 commit 0d1f651
Showing 1 changed file with 10 additions and 10 deletions.
20 changes: 10 additions & 10 deletions src/types/weakref/anyref.rs
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ pub trait PyWeakrefMethods<'py> {
/// 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).
/// In Python it would be equivalent to [`PyWeakref_GetObject`].
/// In Python it would be equivalent to [`PyWeakref_GetRef`].
///
/// # Example
#[cfg_attr(
Expand Down Expand Up @@ -97,7 +97,7 @@ pub trait PyWeakrefMethods<'py> {
/// This function panics is the current object is invalid.
/// If used propperly this is never the case. (NonNull and actually a weakref type)
///
/// [`PyWeakref_GetObject`]: https://docs.python.org/3/c-api/weakref.html#c.PyWeakref_GetObject
/// [`PyWeakref_GetRef`]: https://docs.python.org/3/c-api/weakref.html#c.PyWeakref_GetRef
/// [`weakref.ReferenceType`]: https://docs.python.org/3/library/weakref.html#weakref.ReferenceType
/// [`weakref.ref`]: https://docs.python.org/3/library/weakref.html#weakref.ref
fn upgrade_as<T>(&self) -> PyResult<Option<Bound<'py, T>>>
Expand Down Expand Up @@ -194,7 +194,7 @@ pub trait PyWeakrefMethods<'py> {
/// Upgrade the weakref to a direct Bound object reference unchecked. The type of the recovered object is not checked before downcasting, this could lead to unexpected behavior. Use only when absolutely certain the type can be guaranteed. The `weakref` may still return `None`.
///
/// It is named `upgrade` to be inline with [rust's `Weak::upgrade`](std::rc::Weak::upgrade).
/// In Python it would be equivalent to [`PyWeakref_GetObject`].
/// In Python it would be equivalent to [`PyWeakref_GetRef`].
///
/// # Safety
/// Callers must ensure that the type is valid or risk type confusion.
Expand Down Expand Up @@ -258,7 +258,7 @@ pub trait PyWeakrefMethods<'py> {
/// This function panics is the current object is invalid.
/// If used propperly this is never the case. (NonNull and actually a weakref type)
///
/// [`PyWeakref_GetObject`]: https://docs.python.org/3/c-api/weakref.html#c.PyWeakref_GetObject
/// [`PyWeakref_GetRef`]: https://docs.python.org/3/c-api/weakref.html#c.PyWeakref_GetRef
/// [`weakref.ReferenceType`]: https://docs.python.org/3/library/weakref.html#weakref.ReferenceType
/// [`weakref.ref`]: https://docs.python.org/3/library/weakref.html#weakref.ref
unsafe fn upgrade_as_unchecked<T>(&self) -> Option<Bound<'py, T>> {
Expand Down Expand Up @@ -345,7 +345,7 @@ pub trait PyWeakrefMethods<'py> {
/// Upgrade the weakref to a exact direct Bound object reference.
///
/// It is named `upgrade` to be inline with [rust's `Weak::upgrade`](std::rc::Weak::upgrade).
/// In Python it would be equivalent to [`PyWeakref_GetObject`].
/// In Python it would be equivalent to [`PyWeakref_GetRef`].
///
/// # Example
#[cfg_attr(
Expand Down Expand Up @@ -405,7 +405,7 @@ pub trait PyWeakrefMethods<'py> {
/// This function panics is the current object is invalid.
/// If used propperly this is never the case. (NonNull and actually a weakref type)
///
/// [`PyWeakref_GetObject`]: https://docs.python.org/3/c-api/weakref.html#c.PyWeakref_GetObject
/// [`PyWeakref_GetRef`]: https://docs.python.org/3/c-api/weakref.html#c.PyWeakref_GetRef
/// [`weakref.ReferenceType`]: https://docs.python.org/3/library/weakref.html#weakref.ReferenceType
/// [`weakref.ref`]: https://docs.python.org/3/library/weakref.html#weakref.ref
fn upgrade_as_exact<T>(&self) -> PyResult<Option<Bound<'py, T>>>
Expand Down Expand Up @@ -505,7 +505,7 @@ pub trait PyWeakrefMethods<'py> {
/// This function returns `Some(Bound<'py, PyAny>)` if the reference still exists, otherwise `None` will be returned.
///
/// This function gets the optional target of this [`weakref.ReferenceType`] (result of calling [`weakref.ref`]).
/// It produces similar results to using [`PyWeakref_GetObject`] in the C api.
/// It produces similar results to using [`PyWeakref_GetRef`] in the C api.
///
/// # Example
#[cfg_attr(
Expand Down Expand Up @@ -556,7 +556,7 @@ pub trait PyWeakrefMethods<'py> {
/// This function panics is the current object is invalid.
/// If used propperly this is never the case. (NonNull and actually a weakref type)
///
/// [`PyWeakref_GetObject`]: https://docs.python.org/3/c-api/weakref.html#c.PyWeakref_GetObject
/// [`PyWeakref_GetRef`]: https://docs.python.org/3/c-api/weakref.html#c.PyWeakref_GetRef
/// [`weakref.ReferenceType`]: https://docs.python.org/3/library/weakref.html#weakref.ReferenceType
/// [`weakref.ref`]: https://docs.python.org/3/library/weakref.html#weakref.ref
fn upgrade(&self) -> Option<Bound<'py, PyAny>> {
Expand Down Expand Up @@ -647,7 +647,7 @@ pub trait PyWeakrefMethods<'py> {
/// This function returns `Bound<'py, PyAny>`, which is either the object if it still exists, otherwise it will refer to [`PyNone`](crate::types::PyNone).
///
/// This function gets the optional target of this [`weakref.ReferenceType`] (result of calling [`weakref.ref`]).
/// It produces similar results to using [`PyWeakref_GetObject`] in the C api.
/// It produces similar results to using [`PyWeakref_GetRef`] in the C api.
///
/// # Example
#[cfg_attr(
Expand Down Expand Up @@ -695,7 +695,7 @@ pub trait PyWeakrefMethods<'py> {
/// This function panics is the current object is invalid.
/// If used propperly this is never the case. (NonNull and actually a weakref type)
///
/// [`PyWeakref_GetObject`]: https://docs.python.org/3/c-api/weakref.html#c.PyWeakref_GetObject
/// [`PyWeakref_GetRef`]: https://docs.python.org/3/c-api/weakref.html#c.PyWeakref_GetRef
/// [`weakref.ReferenceType`]: https://docs.python.org/3/library/weakref.html#weakref.ReferenceType
/// [`weakref.ref`]: https://docs.python.org/3/library/weakref.html#weakref.ref
fn get_object(&self) -> Bound<'py, PyAny>;
Expand Down

0 comments on commit 0d1f651

Please sign in to comment.