MCPcopy Create free account
hub / github.com/dgrunwald/rust-cpython / try_borrow

Method try_borrow

src/sharedref.rs:147–152  ·  view source on GitHub ↗

Immutably borrows the wrapped value, returning an error if the value is currently mutably borrowed.

(&self)

Source from the content-addressed store, hash-verified

145 /// Immutably borrows the wrapped value, returning an error if the value
146 /// is currently mutably borrowed.
147 pub fn try_borrow(&self) -> result::Result<Ref<'a, T>, BorrowError> {
148 // state isn't involved since
149 // - data.try_borrow() would fail if self is mutably borrowed,
150 // - and data.try_borrow_mut() would fail while self is borrowed.
151 self.data.try_borrow()
152 }
153
154 /// Mutably borrows the wrapped value.
155 ///

Callers 4

borrowMethod · 0.80
try_leak_immutableMethod · 0.80
test_leaked_borrowFunction · 0.80

Calls 1

validate_generationMethod · 0.80

Tested by 2

test_leaked_borrowFunction · 0.64