55#[ allow( unused_variables) ]
66fn main ( ) {
77
8- // TASK 1 - Option Type Handling
9- // Hint: Option<T> must be explicitly handled
8+ // TASK 1 - ' Option' Type Handling
9+ // Hint: ' Option<T>' must be explicitly handled
1010 let maybe_number = Some ( 42 ) ;
1111 let result = match maybe_number {
1212 Some ( v) => v + 10 ,
1313 None => 0 ,
1414 } ;
1515 println ! ( "TASK1 => result: {}" , result) ;
1616
17- // TASK 2 - Result Variants
18- // Hint: Result uses Ok(T) and Err(E)
17+ // TASK 2 - ' Result' Variants
18+ // Hint: ' Result' uses ' Ok(T)' and ' Err(E)'
1919 fn check_positive ( num : i32 ) -> Result < i32 , String > {
2020 if num > 0 {
2121 Ok ( num) // Replaced Some with Ok
@@ -25,27 +25,27 @@ fn main() {
2525 }
2626 println ! ( "TASK2 => check: {:?}" , check_positive( -5 ) ) ;
2727
28- // TASK 3 - String vs &str
29- // Hint: &str is a fixed view, an owned and growable String is needed to append text
30- let mut greeting = String :: from ( "Hello" ) ; // Converted to an owned String
28+ // TASK 3 - ' String' vs ' &str'
29+ // Hint: ' &str' is a fixed view, an owned and growable ' String' is needed to append text
30+ let mut greeting = String :: from ( "Hello" ) ; // Converted to an owned ' String'
3131 greeting. push_str ( " world" ) ;
3232 println ! ( "TASK3 => greeting: {}" , greeting) ;
3333
34- // TASK 4 - Modifying Strings (push vs push_str)
35- // Hint: Which String method appends a slice instead of a single char?
34+ // TASK 4 - Modifying Strings (' push' vs ' push_str' )
35+ // Hint: Which ' String' method appends a slice instead of a single ' char' ?
3636 let mut text = String :: from ( "Rust" ) ;
37- text. push_str ( " is great" ) ; // Changed push to push_str
37+ text. push_str ( " is great" ) ; // Changed ' push' to ' push_str'
3838 println ! ( "TASK4 => text: {}" , text) ;
3939
4040 // TASK 5 - Vector Creation Macro
4141 // Hint: How is a macro invoked differently than a function?
42- let numbers = vec ! [ 1 , 2 , 3 ] ; // Added ! to properly invoke the macro
42+ let numbers = vec ! [ 1 , 2 , 3 ] ; // Added '!' to properly invoke the macro
4343 println ! ( "TASK5 => numbers length: {}" , numbers. len( ) ) ;
4444
4545 // TASK 6 - Representing Absence
46- // Hint: Rust does not have null pointers, absence is represented by the appropriate Option variant
46+ // Hint: Rust does not have null pointers, absence is represented by the appropriate ' Option' variant
4747 fn get_user ( id : u32 ) -> Option < String > {
48- None // Replaced null with None
48+ None // Replaced null with ' None'
4949 }
5050 println ! ( "TASK6 => get_user(1): {:?}" , get_user( 1 ) ) ;
5151
0 commit comments