From b35f307420f3a0fc633ff7af04e42909bbb4bb8f Mon Sep 17 00:00:00 2001 From: Alisdair Owens Date: Tue, 15 Jul 2014 22:31:55 +0100 Subject: [PATCH] minor improvement to Rc docs to avoid use of unwrap --- src/liballoc/rc.rs | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/src/liballoc/rc.rs b/src/liballoc/rc.rs index d97bce39c2de9..187a2088c27f4 100644 --- a/src/liballoc/rc.rs +++ b/src/liballoc/rc.rs @@ -135,8 +135,9 @@ fn main() { // that their object is still alive, we need to call upgrade() on them // to turn them into a strong reference. This returns an Option, which // contains a reference to our object if it still exists. - let gadget = gadget_opt.upgrade().unwrap(); - println!("Gadget {} owned by {}", gadget.id, gadget.owner.name); + gadget_opt.upgrade().map(|gadget| { + println!("Gadget {} owned by {}", gadget.id, gadget.owner.name); + }); } // At the end of the method, gadget_owner, gadget1 and gadget2 get