In this tutorial, we will learn how to write comments in Rust programming language. We will go through the different types of comments and how to use them in a program.
Comments in Rust are non-executable statements that are used to annotate the code, provide explanations, and make it more readable. They are ignored by the Rust compiler during compilation.
The syntax to define comments in Rust is:
// Single line comment
/* Multi-line comment
continues here */
//
and continue to the end of the line.// Print Hello, World! to the console
fn main() {
println!("Hello, World!");
}
Hello, World!
/*
and end with */
./* Print Hello, World! to the console
This is a multi-line comment */
fn main() {
println!("Hello, World!");
}
Hello, World!