Skip to content

Commit bb5f404

Browse files
chore: Alter whitespace for consistency
* Add newline after "I AM DONE" in exercises for consistency * Remove trailing whitespace from exercises
1 parent 106dbbc commit bb5f404

File tree

10 files changed

+34
-29
lines changed

10 files changed

+34
-29
lines changed

exercises/conversions/as_ref_mut.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33
// and https://doc.rust-lang.org/std/convert/trait.AsMut.html, respectively.
44

55
// I AM NOT DONE
6+
67
// Obtain the number of bytes (not characters) in the given argument
78
// Add the AsRef trait appropriately as a trait bound
89
fn byte_counter<T>(arg: T) -> usize {

exercises/conversions/from_into.rs

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,6 @@ impl Default for Person {
1818
}
1919
}
2020

21-
// I AM NOT DONE
2221
// Your task is to complete this implementation
2322
// in order for the line `let p = Person::from("Mark,20")` to compile
2423
// Please note that you'll need to parse the age component into a `usize`
@@ -33,6 +32,9 @@ impl Default for Person {
3332
// 5. Extract the other element from the split operation and parse it into a `usize` as the age
3433
// If while parsing the age, something goes wrong, then return the default of Person
3534
// Otherwise, then return an instantiated Person object with the results
35+
36+
// I AM NOT DONE
37+
3638
impl From<&str> for Person {
3739
fn from(s: &str) -> Person {
3840
}

exercises/conversions/using_as.rs

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,11 @@
11
// Type casting in Rust is done via the usage of the `as` operator.
22
// Please note that the `as` operator is not only used when type casting.
33
// It also helps with renaming imports.
4+
//
5+
// The goal is to make sure that the division does not fail to compile
46

57
// I AM NOT DONE
6-
// The goal is to make sure that the division does not fail to compile
8+
79
fn average(values: &[f64]) -> f64 {
810
let total = values
911
.iter()
@@ -14,4 +16,4 @@ fn average(values: &[f64]) -> f64 {
1416
fn main() {
1517
let values = [3.5, 0.3, 13.0, 11.7];
1618
println!("{}", average(&values));
17-
}
19+
}

exercises/generics/generics1.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
// This shopping list program isn't compiling!
1+
// This shopping list program isn't compiling!
22
// Use your knowledge of generics to fix it.
33

44
// I AM NOT DONE

exercises/generics/generics2.rs

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22
// Rewrite it using generics so that it supports wrapping ANY type.
33

44
// I AM NOT DONE
5+
56
struct Wrapper {
67
value: u32
78
}
@@ -18,11 +19,11 @@ mod tests {
1819

1920
#[test]
2021
fn store_u32_in_wrapper() {
21-
assert_eq!(Wrapper::new(42).value, 42);
22+
assert_eq!(Wrapper::new(42).value, 42);
2223
}
2324

2425
#[test]
2526
fn store_str_in_wrapper() {
2627
assert_eq!(Wrapper::new("Foo").value, "Foo");
2728
}
28-
}
29+
}

exercises/generics/generics3.rs

Lines changed: 11 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,14 @@
11
// An imaginary magical school has a new report card generation system written in Rust!
2-
// Currently the system only supports creating report cards where the student's grade
3-
// is represented numerically (e.g. 1.0 -> 5.5).
4-
// However, the school also issues alphabetical grades (A+ -> F-) and needs
2+
// Currently the system only supports creating report cards where the student's grade
3+
// is represented numerically (e.g. 1.0 -> 5.5).
4+
// However, the school also issues alphabetical grades (A+ -> F-) and needs
55
// to be able to print both types of report card!
66

7-
// Make the necessary code changes to support alphabetical report cards, thereby making
7+
// Make the necessary code changes to support alphabetical report cards, thereby making
88
// the second test pass.
99

1010
// I AM NOT DONE
11+
1112
pub struct ReportCard {
1213
pub grade: f32,
1314
pub student_name: String,
@@ -16,7 +17,7 @@ pub struct ReportCard {
1617

1718
impl ReportCard {
1819
pub fn print(&self) -> String {
19-
format!("{} ({}) - achieved a grade of {}",
20+
format!("{} ({}) - achieved a grade of {}",
2021
&self.student_name, &self.student_age, &self.grade)
2122
}
2223
}
@@ -28,8 +29,8 @@ mod tests {
2829
#[test]
2930
fn generate_numeric_report_card() {
3031
let report_card = ReportCard {
31-
grade: 2.1,
32-
student_name: "Tom Wriggle".to_string(),
32+
grade: 2.1,
33+
student_name: "Tom Wriggle".to_string(),
3334
student_age: 12,
3435
};
3536
assert_eq!(report_card.print(), "Tom Wriggle (12) - achieved a grade of 2.1");
@@ -39,10 +40,10 @@ mod tests {
3940
fn generate_alphabetic_report_card() {
4041
// TODO: Make sure to change the grade here after you finish the exercise.
4142
let report_card = ReportCard {
42-
grade: 2.1,
43-
student_name: "Gary Plotter".to_string(),
43+
grade: 2.1,
44+
student_name: "Gary Plotter".to_string(),
4445
student_age: 11,
4546
};
4647
assert_eq!(report_card.print(), "Gary Plotter (11) - achieved a grade of A+");
4748
}
48-
}
49+
}

exercises/primitive_types/primitive_types3.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
// primitive_types3.rs
2-
// Create an array with at least 100 elements in it where the ??? is.
2+
// Create an array with at least 100 elements in it where the ??? is.
33
// Execute `rustlings hint primitive_types3` for hints!
44

55
// I AM NOT DONE

exercises/structs/structs3.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,7 @@ mod tests {
4747
fn create_international_package() {
4848
let sender_country = String::from("Spain");
4949
let recipient_country = String::from("Russia");
50-
50+
5151
let package = Package::new(sender_country, recipient_country, 1200);
5252

5353
assert!(package.is_international());
@@ -59,9 +59,9 @@ mod tests {
5959
let recipient_country = String::from("Spain");
6060

6161
let cents_per_kg = ???;
62-
62+
6363
let package = Package::new(sender_country, recipient_country, 1500);
64-
64+
6565
assert_eq!(package.get_fees(cents_per_kg), 4500);
6666
}
6767
}

exercises/traits/traits1.rs

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,21 +1,21 @@
11
// traits1.rs
22
// Time to implement some traits!
3-
//
3+
//
44
// Your task is to implement the trait
55
// `AppendBar' for the type `String'.
6-
//
6+
//
77
// The trait AppendBar has only one function,
88
// which appends "Bar" to any object
99
// implementing this trait.
1010

1111
// I AM NOT DONE
12+
1213
trait AppendBar {
1314
fn append_bar(self) -> Self;
1415
}
1516

1617
impl AppendBar for String {
1718
//Add your code here
18-
1919
}
2020

2121
fn main() {
@@ -40,5 +40,4 @@ mod tests {
4040
String::from("BarBar")
4141
);
4242
}
43-
44-
}
43+
}

exercises/traits/traits2.rs

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,12 @@
11
// traits2.rs
2-
//
2+
//
33
// Your task is to implement the trait
44
// `AppendBar' for a vector of strings.
5-
//
5+
//
66
// To implement this trait, consider for
77
// a moment what it means to 'append "Bar"'
88
// to a vector of strings.
9-
//
9+
//
1010
// No boiler plate code this time,
1111
// you can do this!
1212

@@ -31,5 +31,4 @@ mod tests {
3131
assert_eq!(foo.pop().unwrap(), String::from("Bar"));
3232
assert_eq!(foo.pop().unwrap(), String::from("Foo"));
3333
}
34-
3534
}

0 commit comments

Comments
 (0)