Documentation
0 ↪️ rustlabs
1 ↪️ Why Rust?
2 ↪️ hello world program
3 ↪️ The Basic Formatting
4 ↪️ Printing Styles
5 ↪️ comments
6 ↪️ Challenge 1  Display Output
7 ↪️ solution 1  display output
8 ↪️ challenge 2  display output using placeholders
9 ↪️ solution 2  display output using placeholders
10 ↪️ What Are Variables?
11 ↪️ scope and shadowing
12 ↪️ challenge  defining variables
13 ↪️ Solution  Defining Variables
14 ↪️ what are data types?
15 ↪️ Numeric Types  Integers and Floats
16 ↪️ boolean
17 ↪️ Character and String
18 ↪️ Array
19 ↪️ Tuples
20 ↪️ Constant Variable
21 ↪️ Challenge 1  Declare an Array
22 ↪️ Solution1Declare an Array
23 ↪️ Challenge 2 declare a Tuple
24 ↪️ Solution 2  Declare a Tuple
25 ↪️ Introduction to Operators
26 ↪️ Arithmetic Operators
27 ↪️ Logical Operators
28 ↪️ Comparison Operators
29 ↪️ Bitwise Operators
30 ↪️ Assignment and Compound Assignment Operators
31 ↪️ Type Casting Operator
32 ↪️ Borrowing and Dereferencing Operators
33 ↪️ Precedence and Associativity
34 ↪️ Challenge  Calculate (a + b)^3
35 ↪️ Solution  Calculate (a + b)^3
36 ↪️ If Expression
37 ↪️ If let Expression
38 ↪️ Match Expression
39 ↪️ Comparison of The Different Conditional Constructs
40 ↪️ Challenge 1  Check If Even or Odd
41 ↪️ Solution 1  Check If Even or Odd
42 ↪️ Challenge 2  Make a Calculator
43 ↪️ Solution 2  Make a Calculator
44 ↪️ what is a loop ?
45 ↪️ Definite Loop  For Loop
46 ↪️ Indefinite Loop  While and Loop
47 ↪️ Break Statement
48 ↪️ Continue Statement
49 ↪️ Nested Loops
50 ↪️ Loop Labels
51 ↪️ Challenge 1  Find The Factorial
52 ↪️ Solution 1  Find The Factorial
53 ↪️ Challenge 2  Count Iterations of a Loop Until a Condition
54 ↪️ Solution 2  Count Iterations of a Loop Until a Condition
55 ↪️ Challenge 3  Print a RightAngled Triangle
56 ↪️ Solution 3  Print a RightAngled Triangle
57 ↪️ Introduction to Functions
58 ↪️ Functions With Parameters
59 ↪️ Pass by Value
60 ↪️ Pass by Reference
61 ↪️ Returning a Value From a Function
62 ↪️ Function With Multiple Return Values
63 ↪️ Function With Arrays as Arguments
64 ↪️ Challenge 1  Check Divisibility by 3 and 4
65 ↪️ Solution 1  Check Divisibility by 3 and 4
66 ↪️ Challenge 2  Return an Array of Squares
67 ↪️ Solution 2 Return an Array of Squares
68 ↪️ What Is Recursion?
69 ↪️ Challenge 3  Find nth Fibonacci Number
70 ↪️ Solution 3  Find nth Fibonacci Number
71 ↪️ Introduction to Strings
72 ↪️ Core Methods of String Objects
73 ↪️ Iterating Over Strings
74 ↪️ Updating a String
75 ↪️ Slicing a String
76 ↪️ Functions and Strings
77 ↪️ Challenge  Concatenate Words Starting With 'c'
78 ↪️ solution  Concatenate Words Starting With 'c'
79 ↪️ Introduction to Vectors
80 ↪️ Iterating Over a Vector
81 ↪️ Slicing a Vector
82 ↪️ Challenge  Resizing a Vector
83 ↪️ Solution  Resizing a Vector
84 ↪️ Introduction to Structs
85 ↪️ Functions and Structs
86 ↪️ Methods of Structs
87 ↪️ Static Methods of Structs
88 ↪️ Tuple Structs
89 ↪️ Challenge  Calculate Distance Between Two Points
90 ↪️ Soluation  Calculate Distance Between Two Points
91 ↪️ Introduction to Enums
92 ↪️ Enums With Data Type
93 ↪️ Methods of Enums
94 ↪️ Enums and Match Control Flow Operator
95 ↪️ Enums and Structures
96 ↪️ What Is Option?
97 ↪️ Result and Enum
98 ↪️ Challenge  Find If the Day Is a Weekend
99 ↪️ Solution  Find If the Day Is a Weekend
100 ↪️ Traits
101 ↪️ Generics
102 ↪️ Challenge Check If the Person Has a Driving License
103 ↪️ Solution  Check If the Person Has a Driving License
104 ↪️ Introduction to Modules
105 ↪️ Controlling Visibility Within the Same File Using 'pub'
106 ↪️ Control Visibility Within Different Files Using 'pub'
107 ↪️ The 'use' Keyword
108 ↪️ Challenge  Find the Area of a Triangle
109 ↪️ Solution  Find the Area of a Triangle
110 ↪️ Memory Management
111 ↪️ Ownership
112 ↪️ Copy Type and Moved Type
113 ↪️ Ownership and Functions
114 ↪️ Borrowing
115 ↪️ lifetimes
116 ↪️ lifetimes Elision
comments
Comments
Comments are programmer readable instructions to help explain things about your code. The compiler ignores them.
Types of Comments in Rust
Rust has two types of comments that are commonly used:
Line Comments //
The comments followed by a double forward slash, //
, are known as line comments.
This is the most recommended style of comment for commenting a single line.
// Writing a Rust program
fn main() {
//The line comment is the recommended comment style
println!("This is a line comment!"); // print hello World to the screen
}
Block Comments /*...*/
Text enclosed within /*...*/
is known as a block comment.
This is used for temporarily disabling a large chunk of code.
Doc Comments
The comments followed by ///
or //!
are known as doc comments. Let’s see the difference between the two sets of doc comments.
Outer Doc Comments ///
Outer doc comments are written outside the block of code.
This type of comment supports markdown notation. This is used to generate docs referring to the following item.
Inner Doc Comments //!
Inner doc comments are written inside the block of code.
This comment style is used to generate docs referring to the item within a block of code.
/// This is a Doc comment outside the function
/// Generate docs for the following item.
/// This shows my code outside a module or a function
fn main() {
//! This a doc comment that is inside the function
//! This comment shows my code inside a module or a function
//! Generate docs for the enclosing item
println!("{} can support {} notation","Doc comment","markdown");
}
Quiz
Test your understanding of comments in Rust!

Which type of comment is this?
//
a) Line b) Doc 
Which comment supports markdown notation? a) Line comment b) Doc comment