diff --git a/src/context.rs b/src/context.rs index b6899f8..208dc79 100644 --- a/src/context.rs +++ b/src/context.rs @@ -20,6 +20,7 @@ where pub exercise_04: &'a str, pub exercise_05: &'a str, pub exercise_06: &'a str, + pub exercise_07: &'a str, pub count: usize, } @@ -31,8 +32,9 @@ impl<'a> Default for Exercises<'a> { exercise_03: r#"let mut x = 10;1.x = 15;2.println!("The value of x is: {}", x);"#, exercise_04: r#"let mut y = 20;1.let y_ref1 = &y;2.let y_ref2 = &y;3.println!("y_ref1: {}, y_ref2: {}", y_ref1, y_ref2);4.let y_mut_ref = &mut y;5.println!("y_mut_ref: {}", y_mut_ref);"#, exercise_05: r#"let tuple = (10, 20);1.println!("The elements are: {} {}", tuple.0, tuple.1);2.let (x, y) = tuple;3.println!("Destructured: x = {}, y = {}", x, y);"#, - exercise_06: r#"#[derive(Debug)] struct Vec { x: i32, y: i32 };1.impl std::ops::Add for Vec { type Output = Self; fn add(self, other: Self) -> Self { Self { x: self.x + other.x, y: self.y + other.y } } };2.let v1 = Vec { x: 1, y: 2 };3.let v2 = Vec { x: 3, y: 4 };4.let result = v1 + v2;5.println!("result: {:?}", result);"#, - count: 6, + exercise_06: r#"fn greet() { println!("Hi there!"); };1.fn dice_roll() -> i32 { 4 };2.greet();3.let result = dice_roll(); println!("Dice roll result: {}", result);"#, + exercise_07: r#"#[derive(Debug)] struct Vec { x: i32, y: i32 };1.impl std::ops::Add for Vec { type Output = Self; fn add(self, other: Self) -> Self { Self { x: self.x + other.x, y: self.y + other.y } } };2.let v1 = Vec { x: 1, y: 2 };3.let v2 = Vec { x: 3, y: 4 };4.let result = v1 + v2;5.println!("result: {:?}", result);"#, + count: 7, } } } diff --git a/src/exercises.rs b/src/exercises.rs index 6d19d92..2b9843f 100644 --- a/src/exercises.rs +++ b/src/exercises.rs @@ -4,4 +4,5 @@ pub mod exercise_02; pub mod exercise_03; pub mod exercise_04; pub mod exercise_05; -pub mod exercise_06; \ No newline at end of file +pub mod exercise_06; +pub mod exercise_07; \ No newline at end of file diff --git a/src/exercises/exercise_06.rs b/src/exercises/exercise_06.rs index b9925b8..cd92ab5 100644 --- a/src/exercises/exercise_06.rs +++ b/src/exercises/exercise_06.rs @@ -15,13 +15,13 @@ pub fn Component() -> impl IntoView { view! {
- {r#"In this exercise, we will define a Vec struct with x and y fields and implement the Add operator for it."#} + {r#"In this exercise, we'll define and use functions in Rust."#}
impl IntoView {
impl IntoView {
impl IntoView {
impl IntoView {
{exercise_06[3]}
-
- {exercise_06[4]}
-
-
-
-
- {move || String::from(exercise_06[5])}
-
-
- + {r#"In this exercise, we will define a Vec struct with x and y fields and implement the Add operator for it."#} +
+ +
+ {exercise_07[0]}
+
+
+ {exercise_07[1]}
+
+
+ {exercise_07[2]}
+
+
+ {exercise_07[3]}
+
+
+
+ {exercise_07[4]}
+
+
+
+
+ {move || String::from(exercise_07[5])}
+
+
+