Skip to content

Commit 1c0db24

Browse files
author
Stjepan Glavina
committed
Clarify the docs for Cell::update
1 parent 5dcce51 commit 1c0db24

File tree

1 file changed

+3
-2
lines changed

1 file changed

+3
-2
lines changed

src/libcore/cell.rs

+3-2
Original file line numberDiff line numberDiff line change
@@ -257,7 +257,7 @@ impl<T:Copy> Cell<T> {
257257
unsafe{ *self.value.get() }
258258
}
259259

260-
/// Applies a function to the contained value.
260+
/// Updates the contained value using a function and returns the new value.
261261
///
262262
/// # Examples
263263
///
@@ -267,8 +267,9 @@ impl<T:Copy> Cell<T> {
267267
/// use std::cell::Cell;
268268
///
269269
/// let c = Cell::new(5);
270-
/// c.update(|x| x + 1);
270+
/// let new = c.update(|x| x + 1);
271271
///
272+
/// assert_eq!(new, 6);
272273
/// assert_eq!(c.get(), 6);
273274
/// ```
274275
#[inline]

0 commit comments

Comments
 (0)