From f74f0582296e56a7ba5818e274438941fa593498 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Tomasz=20R=C3=B3=C5=BCa=C5=84ski?= Date: Thu, 27 Jun 2019 13:32:19 +0200 Subject: [PATCH 1/2] Use Field Init Shorthand in the `logon` struct. If a struct field, and variable used to initialize it, have the same name, there's no need to write them both. --- src/std/hash/alt_key_types.md | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/std/hash/alt_key_types.md b/src/std/hash/alt_key_types.md index 8b91a13277..ab94819b25 100644 --- a/src/std/hash/alt_key_types.md +++ b/src/std/hash/alt_key_types.md @@ -50,8 +50,8 @@ fn try_logon<'a>(accounts: &Accounts<'a>, println!("Attempting logon..."); let logon = Account { - username: username, - password: password, + username, + password, }; match accounts.get(&logon) { From 42917744011d9354ec9e26ecd1da059dffa565c3 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Tomasz=20R=C3=B3=C5=BCa=C5=84ski?= Date: Thu, 27 Jun 2019 13:36:56 +0200 Subject: [PATCH 2/2] Use square brackets in `vec!` macro. It's the default behavior of `rust-fmt`, and it's consistent with the rest of examples from the book. --- src/std/hash/hashset.md | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/std/hash/hashset.md b/src/std/hash/hashset.md index a7b3983d7e..63d5af8782 100644 --- a/src/std/hash/hashset.md +++ b/src/std/hash/hashset.md @@ -36,8 +36,8 @@ Try all of these in the following example: use std::collections::HashSet; fn main() { - let mut a: HashSet = vec!(1i32, 2, 3).into_iter().collect(); - let mut b: HashSet = vec!(2i32, 3, 4).into_iter().collect(); + let mut a: HashSet = vec![1i32, 2, 3].into_iter().collect(); + let mut b: HashSet = vec![2i32, 3, 4].into_iter().collect(); assert!(a.insert(4)); assert!(a.contains(&4));