Comments
Documentation
info
This section provides a brief overview of comments (non-doc comments) in Rust. A detailed explanation of doc comments, which are used for generating documentation, will be covered in a separate section.
Comments in Rust are similar to those found in C, C++, and Java. Single-line
comments start with //
, and multi-line comments are enclosed between /*
and
*/
.
Single-Line Comments
main.rs
// This is a single-line comment
fn main() {
println!("Hello, World!"); // This is another single-line comment
}
Multi-Line Comments
main.rs
/* This is a multi-line comment
It can span multiple lines */
fn main() {
println!("Hello, World!");
}