doc.rust-lang.org/core/cell/index.html
Preview meta tags from the doc.rust-lang.org website.
Linked Hostnames
1General Meta Tags
6- titlecore::cell - Rust
- charsetutf-8
- viewportwidth=device-width, initial-scale=1.0
- generatorrustdoc
- descriptionShareable mutable containers.
Link Tags
4- alternate icon../../static.files/favicon-32x32-6580c154.png
- icon../../static.files/favicon-044be391.svg
- stylesheet../../static.files/normalize-9960930a.css
- stylesheet../../static.files/rustdoc-84e720fa.css
Links
3- https://play.rust-lang.org/?code=%23!%5Ballow(unused)%5D%0A%23!%5Ballow(dead_code)%5D%0A%0Afn+main()+%7B%0A++++use+std::cell::OnceCell;%0A++++%0A++++struct+Graph+%7B%0A++++++++edges:+Vec%3C(i32,+i32)%3E,%0A++++++++span_tree_cache:+OnceCell%3CVec%3C(i32,+i32)%3E%3E%0A++++%7D%0A++++%0A++++impl+Graph+%7B%0A++++++++fn+minimum_spanning_tree(%26self)+-%3E+Vec%3C(i32,+i32)%3E+%7B%0A++++++++++++self.span_tree_cache%0A++++++++++++++++.get_or_init(%7C%7C+self.calc_span_tree())%0A++++++++++++++++.clone()%0A++++++++%7D%0A++++%0A++++++++fn+calc_span_tree(%26self)+-%3E+Vec%3C(i32,+i32)%3E+%7B%0A++++++++++++//+Expensive+computation+goes+here%0A++++++++++++vec!%5B%5D%0A++++++++%7D%0A++++%7D%0A%7D&edition=2024
- https://play.rust-lang.org/?code=%23!%5Ballow(unused)%5D%0Afn+main()+%7B%0A++++use+std::cell::Cell;%0A++++use+std::ptr::NonNull;%0A++++use+std::process::abort;%0A++++use+std::marker::PhantomData;%0A++++%0A++++struct+Rc%3CT:+?Sized%3E+%7B%0A++++++++ptr:+NonNull%3CRcInner%3CT%3E%3E,%0A++++++++phantom:+PhantomData%3CRcInner%3CT%3E%3E,%0A++++%7D%0A++++%0A++++struct+RcInner%3CT:+?Sized%3E+%7B%0A++++++++strong:+Cell%3Cusize%3E,%0A++++++++refcount:+Cell%3Cusize%3E,%0A++++++++value:+T,%0A++++%7D%0A++++%0A++++impl%3CT:+?Sized%3E+Clone+for+Rc%3CT%3E+%7B%0A++++++++fn+clone(%26self)+-%3E+Rc%3CT%3E+%7B%0A++++++++++++self.inc_strong();%0A++++++++++++Rc+%7B%0A++++++++++++++++ptr:+self.ptr,%0A++++++++++++++++phantom:+PhantomData,%0A++++++++++++%7D%0A++++++++%7D%0A++++%7D%0A++++%0A++++trait+RcInnerPtr%3CT:+?Sized%3E+%7B%0A++++%0A++++++++fn+inner(%26self)+-%3E+%26RcInner%3CT%3E;%0A++++%0A++++++++fn+strong(%26self)+-%3E+usize+%7B%0A++++++++++++self.inner().strong.get()%0A++++++++%7D%0A++++%0A++++++++fn+inc_strong(%26self)+%7B%0A++++++++++++self.inner()%0A++++++++++++++++.strong%0A++++++++++++++++.set(self.strong()%0A+++++++++++++++++++++++++.checked_add(1)%0A+++++++++++++++++++++++++.unwrap_or_else(%7C%7C+abort()+));%0A++++++++%7D%0A++++%7D%0A++++%0A++++impl%3CT:+?Sized%3E+RcInnerPtr%3CT%3E+for+Rc%3CT%3E+%7B%0A+++++++fn+inner(%26self)+-%3E+%26RcInner%3CT%3E+%7B%0A+++++++++++unsafe+%7B%0A+++++++++++++++self.ptr.as_ref()%0A+++++++++++%7D%0A+++++++%7D%0A++++%7D%0A%7D&edition=2024
- https://play.rust-lang.org/?code=%23!%5Ballow(unused)%5D%0Ause+std::cell::%7BRefCell,+RefMut%7D;%0Ause+std::collections::HashMap;%0Ause+std::rc::Rc;%0A%0Afn+main()+%7B%0A++++let+shared_map:+Rc%3CRefCell%3C_%3E%3E+=+Rc::new(RefCell::new(HashMap::new()));%0A++++//+Create+a+new+block+to+limit+the+scope+of+the+dynamic+borrow%0A++++%7B%0A++++++++let+mut+map:+RefMut%3C'_,+_%3E+=+shared_map.borrow_mut();%0A++++++++map.insert(%22africa%22,+92388);%0A++++++++map.insert(%22kyoto%22,+11837);%0A++++++++map.insert(%22piccadilly%22,+11826);%0A++++++++map.insert(%22marbles%22,+38);%0A++++%7D%0A%0A++++//+Note+that+if+we+had+not+let+the+previous+borrow+of+the+cache+fall+out%0A++++//+of+scope+then+the+subsequent+borrow+would+cause+a+dynamic+thread+panic.%0A++++//+This+is+the+major+hazard+of+using+%60RefCell%60.%0A++++let+total:+i32+=+shared_map.borrow().values().sum();%0A++++println!(%22%7Btotal%7D%22);%0A%7D&edition=2024