From 1fcb9db79c4c55b917c4cccbb06b66a38709f2b9 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Miguel=20Madrid=20Menc=C3=ADa?= Date: Fri, 6 Sep 2019 19:23:44 +0200 Subject: [PATCH] Fix clippy warning in tutorial 3 (#374) - Writing `&String` instead of `&str` involves a new object where a slice will do See https://rust-lang.github.io/rust-clippy/master/#ptr_arg --- doc/tutorial_3.md | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/doc/tutorial_3.md b/doc/tutorial_3.md index e3138d8..8db57ea 100644 --- a/doc/tutorial_3.md +++ b/doc/tutorial_3.md @@ -71,7 +71,7 @@ fn delete_name(s: &mut Cursive) { } } -fn on_submit(s: &mut Cursive, name: &String) { +fn on_submit(s: &mut Cursive, name: &str) { s.pop_layer(); s.add_layer(Dialog::text(format!("Name: {}\nAwesome: yes", name)) .title(format!("{}'s info", name)) @@ -117,14 +117,14 @@ let select = SelectView::::new() We'll also want to add a callback when the user chooses a name. The [`SelectView::on_submit`] method takes a callback with a second argument: the selected item. Since we're using `String`, our callback will have to be - `Fn(&mut Cursive, &String)`: + `Fn(&mut Cursive, &str)`: ```rust,ignore let select = SelectView::::new() .on_submit(on_submit) .fixed_size((10, 5)); -fn on_submit(s: &mut Cursive, name: &String) { +fn on_submit(s: &mut Cursive, name: &str) { s.pop_layer(); s.add_layer(Dialog::text(format!("Name: {}\nAwesome: yes", name)) .title(format!("{}'s info", name))