Skip to content

Commit

Permalink
Fix doctests
Browse files Browse the repository at this point in the history
  • Loading branch information
SimonSapin committed May 27, 2015
1 parent c56c377 commit 04f106f
Showing 1 changed file with 15 additions and 11 deletions.
26 changes: 15 additions & 11 deletions src/libcore/cell.rs
Original file line number Diff line number Diff line change
Expand Up @@ -582,10 +582,11 @@ impl<'b, T: ?Sized> Ref<'b, T> {
/// # Example
///
/// ```
/// use std::cell::{RefCell, Ref, map_ref};
/// # #![feature(cell_extras)]
/// use std::cell::{RefCell, Ref};
///
/// let c = RefCell::new((5, 'b'));
/// let b1: Ref<(u32, char)>> = c.borrow();
/// let b1: Ref<(u32, char)> = c.borrow();
/// let b2: Ref<u32> = Ref::map(b1, |t| &t.0);
/// assert_eq!(*b2, 5)
/// ```
Expand All @@ -611,12 +612,13 @@ impl<'b, T: ?Sized> Ref<'b, T> {
/// # Example
///
/// ```
/// use std::cell::{RefCell, Ref, map_ref};
/// # #![feature(cell_extras)]
/// use std::cell::{RefCell, Ref};
///
/// let c = RefCell::new(Ok(5));
/// let b1: Ref<Result<u32, ()>> = c.borrow();
/// let b2: Option<Ref<u32>> = Ref::filter_map(b1, |o| o.as_ref().ok());
/// assert_eq!(*b2.unwrap(), 5)
/// let b2: Ref<u32> = Ref::filter_map(b1, |o| o.as_ref().ok()).unwrap();
/// assert_eq!(*b2, 5)
/// ```
#[unstable(feature = "cell_extras", reason = "recently added")]
#[inline]
Expand All @@ -642,12 +644,13 @@ impl<'b, T: ?Sized> RefMut<'b, T> {
/// # Example
///
/// ```
/// use std::cell::{RefCell, RefMut, map_ref_mut};
/// # #![feature(cell_extras)]
/// use std::cell::{RefCell, RefMut};
///
/// let c = RefCell::new((5, 'b'));
/// {
/// let b1: RefMut<(u32, char)> = c.borrow_mut();
/// let b2: RefMut<u32> = RefMut::map(b1, |t| &mut t.0);
/// let mut b2: RefMut<u32> = RefMut::map(b1, |t| &mut t.0);
/// assert_eq!(*b2, 5);
/// *b2 = 42;
/// }
Expand Down Expand Up @@ -675,14 +678,15 @@ impl<'b, T: ?Sized> RefMut<'b, T> {
/// # Example
///
/// ```
/// use std::cell::{RefCell, RefMut, map_ref_mut};
/// # #![feature(cell_extras)]
/// use std::cell::{RefCell, RefMut};
///
/// let c = RefCell::new(Ok(5));
/// {
/// let b1: RefMut<Result<u32, ()>> = c.borrow_mut();
/// let b2: Option<RefMut<u32>> = RefMut::map(b1, |o| o.as_mut().ok());
/// assert_eq!(*b2.unwrap(), 5);
/// *b2.unwrap() = 42;
/// let mut b2: RefMut<u32> = RefMut::filter_map(b1, |o| o.as_mut().ok()).unwrap();
/// assert_eq!(*b2, 5);
/// *b2 = 42;
/// }
/// assert_eq!(*c.borrow(), Ok(42));
/// ```
Expand Down

0 comments on commit 04f106f

Please sign in to comment.