Skip to content

Commit 7850a73

Browse files
authored
Merge pull request rust-lang#2324 from JatinSanghvi/main
fix: Match solution files with exercise files
2 parents b5d440f + 1ebb4d2 commit 7850a73

File tree

6 files changed

+19
-19
lines changed

6 files changed

+19
-19
lines changed

solutions/09_strings/strings4.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ fn main() {
1919
// `.into()` converts a type into an expected type.
2020
// If it is called where `String` is expected, it will convert `&str` to `String`.
2121
string("nice weather".into());
22-
// But if it is called where `&str` is expected, then `&str` is kept `&str` since no conversion is needed.
22+
// But if it is called where `&str` is expected, then `&str` is kept as `&str` since no conversion is needed.
2323
// If you remove the `#[allow(…)]` line, then Clippy will tell you to remove `.into()` below since it is a useless conversion.
2424
#[allow(clippy::useless_conversion)]
2525
string_slice("nice weather".into());

solutions/11_hashmaps/hashmaps1.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
// A basket of fruits in the form of a hash map needs to be defined. The key
22
// represents the name of the fruit and the value represents how many of that
33
// particular fruit is in the basket. You have to put at least 3 different
4-
// types of fruits (e.g apple, banana, mango) in the basket and the total count
4+
// types of fruits (e.g. apple, banana, mango) in the basket and the total count
55
// of all the fruits should be at least 5.
66

77
use std::collections::HashMap;

solutions/12_options/options1.rs

Lines changed: 13 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
1-
// This function returns how much icecream there is left in the fridge.
1+
// This function returns how much ice cream there is left in the fridge.
22
// If it's before 22:00 (24-hour system), then 5 scoops are left. At 22:00,
3-
// someone eats it all, so no icecream is left (value 0). Return `None` if
3+
// someone eats it all, so no ice cream is left (value 0). Return `None` if
44
// `hour_of_day` is higher than 23.
5-
fn maybe_icecream(hour_of_day: u16) -> Option<u16> {
5+
fn maybe_ice_cream(hour_of_day: u16) -> Option<u16> {
66
match hour_of_day {
77
0..=21 => Some(5),
88
22..=23 => Some(0),
@@ -21,19 +21,19 @@ mod tests {
2121
#[test]
2222
fn raw_value() {
2323
// Using `unwrap` is fine in a test.
24-
let icecreams = maybe_icecream(12).unwrap();
24+
let ice_creams = maybe_ice_cream(12).unwrap();
2525

26-
assert_eq!(icecreams, 5);
26+
assert_eq!(ice_creams, 5);
2727
}
2828

2929
#[test]
30-
fn check_icecream() {
31-
assert_eq!(maybe_icecream(0), Some(5));
32-
assert_eq!(maybe_icecream(9), Some(5));
33-
assert_eq!(maybe_icecream(18), Some(5));
34-
assert_eq!(maybe_icecream(22), Some(0));
35-
assert_eq!(maybe_icecream(23), Some(0));
36-
assert_eq!(maybe_icecream(24), None);
37-
assert_eq!(maybe_icecream(25), None);
30+
fn check_ice_cream() {
31+
assert_eq!(maybe_ice_cream(0), Some(5));
32+
assert_eq!(maybe_ice_cream(9), Some(5));
33+
assert_eq!(maybe_ice_cream(18), Some(5));
34+
assert_eq!(maybe_ice_cream(22), Some(0));
35+
assert_eq!(maybe_ice_cream(23), Some(0));
36+
assert_eq!(maybe_ice_cream(24), None);
37+
assert_eq!(maybe_ice_cream(25), None);
3838
}
3939
}

solutions/13_error_handling/errors5.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66
//
77
// In short, this particular use case for boxes is for when you want to own a
88
// value and you care only that it is a type which implements a particular
9-
// trait. To do so, The `Box` is declared as of type `Box<dyn Trait>` where
9+
// trait. To do so, the `Box` is declared as of type `Box<dyn Trait>` where
1010
// `Trait` is the trait the compiler looks for on any value used in that
1111
// context. For this exercise, that context is the potential errors which
1212
// can be returned in a `Result`.

solutions/16_lifetimes/lifetimes2.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ fn longest<'a>(x: &'a str, y: &'a str) -> &'a str {
44

55
fn main() {
66
let string1 = String::from("long string is long");
7-
// Solution1: You can move `strings2` out of the inner block so that it is
7+
// Solution 1: You can move `strings2` out of the inner block so that it is
88
// not dropped before the print statement.
99
let string2 = String::from("xyz");
1010
let result;
@@ -21,7 +21,7 @@ fn main() {
2121
{
2222
let string2 = String::from("xyz");
2323
result = longest(&string1, &string2);
24-
// Solution2: You can move the print statement into the inner block so
24+
// Solution 2: You can move the print statement into the inner block so
2525
// that it is executed before `string2` is dropped.
2626
println!("The longest string is '{result}'");
2727
// `string2` dropped here (end of the inner scope).

solutions/21_macros/macros3.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
// Added the attribute `macro_use` attribute.
1+
// Added the `macro_use` attribute.
22
#[macro_use]
33
mod macros {
44
macro_rules! my_macro {

0 commit comments

Comments
 (0)