Struct PyRefMut
pub struct PyRefMut<'p, T>where
T: PyClass<Frozen = False>,{ /* private fields */ }tls only.Expand description
A wrapper type for a mutably borrowed value from a Bound<'py, T>.
See the module-level documentation for more information.
Implementations§
§impl<'py, T> PyRefMut<'py, T>where
T: PyClass<Frozen = False>,
impl<'py, T> PyRefMut<'py, T>where
T: PyClass<Frozen = False>,
pub 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.
pub 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).
§impl<'p, T> PyRefMut<'p, T>
impl<'p, T> PyRefMut<'p, T>
pub fn into_super(self) -> PyRefMut<'p, <T as PyClassImpl>::BaseType>
pub fn into_super(self) -> PyRefMut<'p, <T as PyClassImpl>::BaseType>
Gets a PyRef<T::BaseType>.
See PyRef::into_super for more.
pub fn as_super(&mut self) -> &mut PyRefMut<'p, <T as PyClassImpl>::BaseType>
pub fn as_super(&mut self) -> &mut PyRefMut<'p, <T as PyClassImpl>::BaseType>
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§
§impl<'a, 'py, T> FromPyObject<'a, 'py> for PyRefMut<'py, T>where
T: PyClass<Frozen = False>,
impl<'a, 'py, T> FromPyObject<'a, 'py> for PyRefMut<'py, T>where
T: PyClass<Frozen = False>,
§impl<'a, 'py, T> IntoPyObject<'py> for &'a PyRefMut<'py, T>where
T: PyClass<Frozen = False>,
impl<'a, 'py, T> IntoPyObject<'py> for &'a PyRefMut<'py, T>where
T: PyClass<Frozen = False>,
§type Error = Infallible
type Error = Infallible
§fn into_pyobject(
self,
_py: Python<'py>,
) -> Result<<&'a PyRefMut<'py, T> as IntoPyObject<'py>>::Output, <&'a PyRefMut<'py, T> as IntoPyObject<'py>>::Error>
fn into_pyobject( self, _py: Python<'py>, ) -> Result<<&'a PyRefMut<'py, T> as IntoPyObject<'py>>::Output, <&'a PyRefMut<'py, T> as IntoPyObject<'py>>::Error>
§impl<'py, T> IntoPyObject<'py> for PyRefMut<'py, T>where
T: PyClass<Frozen = False>,
impl<'py, T> IntoPyObject<'py> for PyRefMut<'py, T>where
T: PyClass<Frozen = False>,
§type Error = Infallible
type Error = Infallible
§fn into_pyobject(
self,
_py: Python<'py>,
) -> Result<<PyRefMut<'py, T> as IntoPyObject<'py>>::Output, <PyRefMut<'py, T> as IntoPyObject<'py>>::Error>
fn into_pyobject( self, _py: Python<'py>, ) -> Result<<PyRefMut<'py, T> as IntoPyObject<'py>>::Output, <PyRefMut<'py, T> as IntoPyObject<'py>>::Error>
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> UnsafeUnpin for PyRefMut<'p, T>
impl<'p, T> UnwindSafe for PyRefMut<'p, T>where
T: UnwindSafe,
Blanket Implementations§
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
§impl<T> Instrument for T
impl<T> Instrument for T
§fn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
§fn in_current_span(self) -> Instrumented<Self>
fn in_current_span(self) -> Instrumented<Self>
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 more§impl<'py, T> IntoPyObjectExt<'py> for Twhere
T: IntoPyObject<'py>,
impl<'py, T> IntoPyObjectExt<'py> for Twhere
T: IntoPyObject<'py>,
§fn into_bound_py_any(self, py: Python<'py>) -> Result<Bound<'py, PyAny>, PyErr>
fn into_bound_py_any(self, py: Python<'py>) -> Result<Bound<'py, PyAny>, PyErr>
self into an owned Python object, dropping type information.§impl<T> Pointable for T
impl<T> Pointable for T
Source§impl<R> Rng for R
impl<R> Rng for R
Source§fn random<T>(&mut self) -> Twhere
StandardUniform: Distribution<T>,
fn random<T>(&mut self) -> Twhere
StandardUniform: Distribution<T>,
StandardUniform distribution. Read moreSource§fn random_iter<T>(self) -> Iter<StandardUniform, Self, T>
fn random_iter<T>(self) -> Iter<StandardUniform, Self, T>
Source§fn random_range<T, R>(&mut self, range: R) -> Twhere
T: SampleUniform,
R: SampleRange<T>,
fn random_range<T, R>(&mut self, range: R) -> Twhere
T: SampleUniform,
R: SampleRange<T>,
Source§fn random_bool(&mut self, p: f64) -> bool
fn random_bool(&mut self, p: f64) -> bool
p of being true. Read moreSource§fn random_ratio(&mut self, numerator: u32, denominator: u32) -> bool
fn random_ratio(&mut self, numerator: u32, denominator: u32) -> bool
numerator/denominator of being
true. Read moreSource§fn sample<T, D>(&mut self, distr: D) -> Twhere
D: Distribution<T>,
fn sample<T, D>(&mut self, distr: D) -> Twhere
D: Distribution<T>,
Source§fn sample_iter<T, D>(self, distr: D) -> Iter<D, Self, T>where
D: Distribution<T>,
Self: Sized,
fn sample_iter<T, D>(self, distr: D) -> Iter<D, Self, T>where
D: Distribution<T>,
Self: Sized,
Source§fn gen<T>(&mut self) -> Twhere
StandardUniform: Distribution<T>,
fn gen<T>(&mut self) -> Twhere
StandardUniform: Distribution<T>,
Renamed to random to avoid conflict with the new gen keyword in Rust 2024.
Rng::random.Source§fn gen_range<T, R>(&mut self, range: R) -> Twhere
T: SampleUniform,
R: SampleRange<T>,
fn gen_range<T, R>(&mut self, range: R) -> Twhere
T: SampleUniform,
R: SampleRange<T>,
Renamed to random_range
Rng::random_range.Source§impl<R> TryRngCore for R
impl<R> TryRngCore for R
Source§type Error = Infallible
type Error = Infallible
Source§fn try_next_u32(&mut self) -> Result<u32, <R as TryRngCore>::Error>
fn try_next_u32(&mut self) -> Result<u32, <R as TryRngCore>::Error>
u32.Source§fn try_next_u64(&mut self) -> Result<u64, <R as TryRngCore>::Error>
fn try_next_u64(&mut self) -> Result<u64, <R as TryRngCore>::Error>
u64.Source§fn try_fill_bytes(
&mut self,
dst: &mut [u8],
) -> Result<(), <R as TryRngCore>::Error>
fn try_fill_bytes( &mut self, dst: &mut [u8], ) -> Result<(), <R as TryRngCore>::Error>
dest entirely with random data.Source§fn unwrap_mut(&mut self) -> UnwrapMut<'_, Self>
fn unwrap_mut(&mut self) -> UnwrapMut<'_, Self>
UnwrapMut wrapper.Source§fn read_adapter(&mut self) -> RngReadAdapter<'_, Self>where
Self: Sized,
fn read_adapter(&mut self) -> RngReadAdapter<'_, Self>where
Self: Sized,
std only.RngCore to a RngReadAdapter.