We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
1 parent 5dcce51 commit 1c0db24Copy full SHA for 1c0db24
src/libcore/cell.rs
@@ -257,7 +257,7 @@ impl<T:Copy> Cell<T> {
257
unsafe{ *self.value.get() }
258
}
259
260
- /// Applies a function to the contained value.
+ /// Updates the contained value using a function and returns the new value.
261
///
262
/// # Examples
263
@@ -267,8 +267,9 @@ impl<T:Copy> Cell<T> {
267
/// use std::cell::Cell;
268
269
/// let c = Cell::new(5);
270
- /// c.update(|x| x + 1);
+ /// let new = c.update(|x| x + 1);
271
272
+ /// assert_eq!(new, 6);
273
/// assert_eq!(c.get(), 6);
274
/// ```
275
#[inline]
0 commit comments