We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
1 parent ae3d387 commit c288864Copy full SHA for c288864
src/libcore/cell.rs
@@ -391,17 +391,17 @@ impl<T> Cell<T> {
391
}
392
393
394
- /// Replaces the contained value.
+ /// Replaces the contained value, and returns it.
395
///
396
/// # Examples
397
398
/// ```
399
/// use std::cell::Cell;
400
401
- /// let c = Cell::new(5);
402
- /// let old = c.replace(10);
403
- ///
404
- /// assert_eq!(5, old);
+ /// let cell = Cell::new(5);
+ /// assert_eq!(cell.get(), 5);
+ /// assert_eq!(cell.replace(10), 5);
+ /// assert_eq!(cell.get(), 10);
405
406
#[stable(feature = "move_cell", since = "1.17.0")]
407
pub fn replace(&self, val: T) -> T {
0 commit comments