Skip to content

Commit 13c16e3

Browse files
committed
Use OnceCell in cell module documentation
1 parent abe34e9 commit 13c16e3

File tree

1 file changed

+4
-4
lines changed

1 file changed

+4
-4
lines changed

library/core/src/cell.rs

+4-4
Original file line numberDiff line numberDiff line change
@@ -143,17 +143,17 @@
143143
//!
144144
//! ```
145145
//! # #![allow(dead_code)]
146-
//! use std::cell::RefCell;
146+
//! use std::cell::OnceCell;
147147
//!
148148
//! struct Graph {
149149
//! edges: Vec<(i32, i32)>,
150-
//! span_tree_cache: RefCell<Option<Vec<(i32, i32)>>>
150+
//! span_tree_cache: OnceCell<Vec<(i32, i32)>>
151151
//! }
152152
//!
153153
//! impl Graph {
154154
//! fn minimum_spanning_tree(&self) -> Vec<(i32, i32)> {
155-
//! self.span_tree_cache.borrow_mut()
156-
//! .get_or_insert_with(|| self.calc_span_tree())
155+
//! self.span_tree_cache
156+
//! .get_or_init(|| self.calc_span_tree())
157157
//! .clone()
158158
//! }
159159
//!

0 commit comments

Comments
 (0)