pub unsafe fn try_borrow_unguarded(&self) -> Result<&T, PyBorrowError> {
        if self.get_borrow_flag() == BorrowFlag::HAS_MUTABLE_BORROW {
            Err(PyBorrowError { _private: () })
        } else {
            Ok(&*self.contents.value.get())
        }
    }
/// Immutably borrows the value `T`, returning an error if the value is
/// currently mutably borrowed.
///
/// # Safety
///
/// This method is unsafe because it does not return a `PyRef`,
/// thus leaving the borrow flag untouched. Mutably borrowing the `PyCell`
/// while the reference returned by this method is alive is undefined behaviour.
///
/// # Examples
///
/// ```
/// # use pyo3::prelude::*;
/// #[pyclass]
/// struct Class {}
/// Python::with_gil(|py| {
///     let c = PyCell::new(py, Class {}).unwrap();
///
///     {
///         let m = c.borrow_mut();
///         assert!(unsafe { c.try_borrow_unguarded() }.is_err());
///     }
///
///     {
///         let m = c.borrow();
///         assert!(unsafe { c.try_borrow_unguarded() }.is_ok());
///     }
/// });
/// ```
Immutably borrows the value `T`, returning an error if the value is
currently mutably borrowed.
Immutably borrows the value ` T ` returning an error if the value is currently mutably borrowed .
pub unsafe fn try_borrow_unguarded(&self) -> Result<&T, PyBorrowError> {
        if self.get_borrow_flag() == BorrowFlag::HAS_MUTABLE_BORROW {
            Err(PyBorrowError { _private: () })
        } else {
            Ok(&*self.contents.value.get())
        }
    }
pub unsafe fn try_borrow_unguarded ( & self ) -> Result < & T , PyBorrowError > { if self . get_borrow_flag ( ) == BorrowFlag :: HAS_MUTABLE_BORROW { Err ( PyBorrowError { _private : ( ) } ) } else { Ok ( & * self . contents . value . get ( ) ) } }
Immutably borrows the value `T`, returning an error if the value is
currently mutably borrowed.
Immutably borrows the value ` T ` returning an error if the value is currently mutably borrowed .
&self
&self
safety
This method is unsafe because it does not return a `PyRef`,
thus leaving the borrow flag untouched. Mutably borrowing the `PyCell`
while the reference returned by this method is alive is undefined behaviour.
This method is unsafe because it does not return a ` PyRef ` thus leaving the borrow flag untouched . Mutably borrowing the ` PyCell ` while the reference returned by this method is alive is undefined behaviour .
examples
None
use pyo3::prelude::*;
None
[pyclass]
struct Class {}
Python::with_gil(|py| {
let c = PyCell::new(py, Class {}).unwrap().

{
let m = c.borrow_mut();
assert!(unsafe { c.try_borrow_unguarded() }.is_err());
}


struct Class {} Python :: with_gil ( |py| { let c = PyCell :: new ( py Class {} ) . unwrap () . { let m = c . borrow_mut () ; assert! ( unsafe { c . try_borrow_unguarded () } . is_err () ) ; }