#[repr(transparent)]pub struct PyRefMut<'p, T: PyClass<Frozen = False>> {
inner: Bound<'p, T>,
}
Expand description
A wrapper type for a mutably borrowed value from a [Bound<'py, T>
].
See the module-level documentation for more information.
Fields§
§inner: Bound<'p, T>
Implementations§
Source§impl<'py, T: PyClass<Frozen = False>> PyRefMut<'py, T>
impl<'py, T: PyClass<Frozen = False>> PyRefMut<'py, T>
Sourcepub fn as_ptr(&self) -> *mut PyObject
pub fn as_ptr(&self) -> *mut PyObject
Returns the raw FFI pointer represented by self.
§Safety
Callers are responsible for ensuring that the pointer does not outlive self.
The reference is borrowed; callers should not decrease the reference count when they are finished with the pointer.
Sourcepub fn into_ptr(self) -> *mut PyObject
pub fn into_ptr(self) -> *mut PyObject
Returns an owned raw FFI pointer represented by self.
§Safety
The reference is owned; when finished the caller should either transfer ownership
of the pointer or decrease the reference count (e.g. with pyo3::ffi::Py_DecRef
).
pub(crate) fn borrow(obj: &Bound<'py, T>) -> Self
pub(crate) fn try_borrow(obj: &Bound<'py, T>) -> Result<Self, PyBorrowMutError>
pub(crate) fn downgrade(slf: &Self) -> &PyRef<'py, T>
Source§impl<'p, T, U> PyRefMut<'p, T>
impl<'p, T, U> PyRefMut<'p, T>
Sourcepub fn into_super(self) -> PyRefMut<'p, U>
pub fn into_super(self) -> PyRefMut<'p, U>
Gets a PyRef<T::BaseType>
.
See PyRef::into_super
for more.
Sourcepub fn as_super(&mut self) -> &mut PyRefMut<'p, U>
pub fn as_super(&mut self) -> &mut PyRefMut<'p, U>
Borrows a mutable reference to PyRefMut<T::BaseType>
.
With the help of this method, you can mutate attributes and call mutating
methods on the superclass without consuming the PyRefMut<T>
. This method
can also be chained to access the super-superclass (and so on).
See PyRef::as_super
for more.
Trait Implementations§
Source§impl<'py, T> FromPyObject<'py> for PyRefMut<'py, T>
impl<'py, T> FromPyObject<'py> for PyRefMut<'py, T>
Source§impl<'a, 'py, T: PyClass<Frozen = False>> IntoPyObject<'py> for &'a PyRefMut<'py, T>
impl<'a, 'py, T: PyClass<Frozen = False>> IntoPyObject<'py> for &'a PyRefMut<'py, T>
Source§type Error = Infallible
type Error = Infallible
Source§fn into_pyobject(self, _py: Python<'py>) -> Result<Self::Output, Self::Error>
fn into_pyobject(self, _py: Python<'py>) -> Result<Self::Output, Self::Error>
Source§fn type_output() -> TypeInfo
fn type_output() -> TypeInfo
experimental-inspect
only.Source§#[doc(hidden)] fn owned_sequence_into_pyobject<I>(
iter: I,
py: Python<'py>,
_: Token,
) -> Result<Bound<'py, PyAny>, PyErr>
#[doc(hidden)] fn owned_sequence_into_pyobject<I>( iter: I, py: Python<'py>, _: Token, ) -> Result<Bound<'py, PyAny>, PyErr>
Vec<u8>
, [u8; N]
and SmallVec<[u8; N]>
as a sequence of bytes into a bytes
object.Source§#[doc(hidden)] fn borrowed_sequence_into_pyobject<I>(
iter: I,
py: Python<'py>,
_: Token,
) -> Result<Bound<'py, PyAny>, PyErr>where
Self: Reference,
I: IntoIterator<Item = Self> + AsRef<[<Self as Reference>::BaseType]>,
I::IntoIter: ExactSizeIterator<Item = Self>,
#[doc(hidden)] fn borrowed_sequence_into_pyobject<I>(
iter: I,
py: Python<'py>,
_: Token,
) -> Result<Bound<'py, PyAny>, PyErr>where
Self: Reference,
I: IntoIterator<Item = Self> + AsRef<[<Self as Reference>::BaseType]>,
I::IntoIter: ExactSizeIterator<Item = Self>,
&[u8]
and Cow<[u8]>
as a sequence of bytes into a bytes
object.Source§impl<'py, T: PyClass<Frozen = False>> IntoPyObject<'py> for PyRefMut<'py, T>
impl<'py, T: PyClass<Frozen = False>> IntoPyObject<'py> for PyRefMut<'py, T>
Source§type Error = Infallible
type Error = Infallible
Source§fn into_pyobject(self, _py: Python<'py>) -> Result<Self::Output, Self::Error>
fn into_pyobject(self, _py: Python<'py>) -> Result<Self::Output, Self::Error>
Source§fn type_output() -> TypeInfo
fn type_output() -> TypeInfo
experimental-inspect
only.Auto Trait Implementations§
impl<'p, T> Freeze for PyRefMut<'p, T>
impl<'p, T> RefUnwindSafe for PyRefMut<'p, T>where
T: RefUnwindSafe,
impl<'p, T> !Send for PyRefMut<'p, T>
impl<'p, T> !Sync for PyRefMut<'p, T>
impl<'p, T> Unpin for PyRefMut<'p, T>where
T: Unpin,
impl<'p, T> UnwindSafe for PyRefMut<'p, T>where
T: UnwindSafe,
Blanket Implementations§
Source§impl<T> AssertNotZeroSized for T
impl<T> AssertNotZeroSized for T
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Source§impl<'py, T> FromPyObjectBound<'_, 'py> for Twhere
T: FromPyObject<'py>,
impl<'py, T> FromPyObjectBound<'_, 'py> for Twhere
T: FromPyObject<'py>,
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self>
fn into_either(self, into_left: bool) -> Either<Self, Self>
self
into a Left
variant of Either<Self, Self>
if into_left
is true
.
Converts self
into a Right
variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
self
into a Left
variant of Either<Self, Self>
if into_left(&self)
returns true
.
Converts self
into a Right
variant of Either<Self, Self>
otherwise. Read moreSource§impl<'py, T> IntoPyCallbackOutput<'py, *mut PyObject> for Twhere
T: IntoPyObject<'py>,
impl<'py, T> IntoPyCallbackOutput<'py, *mut PyObject> for Twhere
T: IntoPyObject<'py>,
Source§impl<'py, T> IntoPyCallbackOutput<'py, Py<PyAny>> for Twhere
T: IntoPyObject<'py>,
impl<'py, T> IntoPyCallbackOutput<'py, Py<PyAny>> for Twhere
T: IntoPyObject<'py>,
Source§impl<'py, T> IntoPyObjectExt<'py> for Twhere
T: IntoPyObject<'py>,
impl<'py, T> IntoPyObjectExt<'py> for Twhere
T: IntoPyObject<'py>,
Source§fn into_bound_py_any(self, py: Python<'py>) -> PyResult<Bound<'py, PyAny>>
fn into_bound_py_any(self, py: Python<'py>) -> PyResult<Bound<'py, PyAny>>
self
into an owned Python object, dropping type information.