From f7b639758834e6fc7ae51eff5b76730eb9309d9c Mon Sep 17 00:00:00 2001 From: Alexandre Bury Date: Sun, 26 Mar 2017 20:53:34 -0700 Subject: [PATCH] Update tutorial_3 Remove extra Rc clones, add missing link. --- doc/tutorial_3.md | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/doc/tutorial_3.md b/doc/tutorial_3.md index 8469958..a63460e 100644 --- a/doc/tutorial_3.md +++ b/doc/tutorial_3.md @@ -54,7 +54,7 @@ fn add_name(s: &mut Cursive) { .button("Ok", |s| { let name = s.call_on_id("name", |view: &mut EditView| { - view.get_content().clone() + view.get_content() }).unwrap(); ok(s, &name); }) @@ -240,7 +240,7 @@ fn add_name(s: &mut Cursive) { .title("Enter a new name") .button("Ok", |s| { let name = s.call_on_id("name", |view: &mut EditView| { - view.get_content().clone() + view.get_content() }).unwrap(); }) .button("Cancel", |s| s.pop_layer())); @@ -280,7 +280,7 @@ fn add_name(s: &mut Cursive) { .title("Enter a new name") .button("Ok", |s| { let name = s.call_on_id("name", |v: &mut EditView| { - v.get_content().clone() + v.get_content() }).unwrap(); ok(s, &name); }) @@ -306,7 +306,7 @@ fn delete_name(s: &mut Cursive) { We use [`SelectView::selected_id`] and [`SelectView::remove_item`] to remove the item currently selected, nothing too surprising. -But this time, instead of using `call_on_id`, we use `Cursive::find_id`: +But this time, instead of using `call_on_id`, we use [`Cursive::find_id`]: this method returns a handle, through which we can mutate the view. It uses `Rc` and `RefCell` under the hood to provide mutable access to the view without borrowing the `Cursive` root, leaving us free to pop layers.