std-method
Rust RefCell::borrow
Acquire a read guard. Additional shared reads are allowed while no exclusive runtime borrow is active. The panicking form is useful when a conflict represents a programming error. Expected output (not executed): 18 Why: Both guards read the same integer. Common mistake: Keeping a read guard alive while requesting a writer.
Formal Syntax & Structure
rust syntaxrust
cell.borrow() -> Ref<'_, T>Working Example
Example Snippetrust
use std::cell::RefCell;fn main() { let data = RefCell::new(9); let a = data.borrow(); let b = data.borrow(); println!("{}", *a + *b);}