Struct cpython::PySharedRef
source · pub struct PySharedRef<'a, T: 'a + ?Sized> { /* private fields */ }
Expand description
A reference to PySharedRefCell
owned by a Python object.
This is a lifetime-bound reference to the PySharedRefCell data field, and will be created by the automatically generated accessor function.
ⓘ
impl MyType {
fn data_name<'a>(&'a self, py: Python<'a>) -> PySharedRef<'a, T> { ... }
}
Implementations§
sourcepub fn try_borrow(&self) -> Result<Ref<'a, T>, BorrowError>
pub fn try_borrow(&self) -> Result<Ref<'a, T>, BorrowError>
Immutably borrows the wrapped value, returning an error if the value is currently mutably borrowed.
sourcepub fn borrow_mut(&self) -> RefMut<'a, T>
pub fn borrow_mut(&self) -> RefMut<'a, T>
Mutably borrows the wrapped value.
Any existing leaked references will be invalidated.
§Panics
Panics if the value is currently borrowed.
sourcepub fn try_borrow_mut(&self) -> Result<RefMut<'a, T>, BorrowMutError>
pub fn try_borrow_mut(&self) -> Result<RefMut<'a, T>, BorrowMutError>
Mutably borrows the wrapped value, returning an error if the value is currently borrowed.
sourcepub fn leak_immutable(&self) -> UnsafePyLeaked<&'static T>
pub fn leak_immutable(&self) -> UnsafePyLeaked<&'static T>
Creates an immutable reference which is not bound to lifetime.
§Panics
Panics if the value is currently mutably borrowed.
sourcepub fn try_leak_immutable(
&self
) -> Result<UnsafePyLeaked<&'static T>, BorrowError>
pub fn try_leak_immutable( &self ) -> Result<UnsafePyLeaked<&'static T>, BorrowError>
Creates an immutable reference which is not bound to lifetime, returning an error if the value is currently mutably borrowed.
Auto Trait Implementations§
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
Mutably borrows from an owned value. Read more