Rust Comments

In this tutorial you will learn about the Rust Comments and its application with practical example.

Rust Comments

Rust Comments are a set of statements that are not executed by the Rust compiler and interpreter. The use of comments makes it easy for humans to understand the source code.Usually comments gives you inside or explanation about the variable, method, class or any statement that exists in source code. The comment statements are ignored during the execution of the program.

Rust Single-line Comments:-

A ‘//’ (double forward slash) is used to specify a single line comment, which extends up to the newline character.

Output:-

Rust Multi-line Comments:-

If you want to comment multiple lines then you can do it using /* and */, everything in between from /* to */ is ignored by the compiler-

Output:-

Doc Comments in Rust

In Rust, Doc Comments is a string that is used to specify what a function/class/module does. It usually appear as first statement in a module, function, class, or method definition. A ‘///’ (triple forward slash) is used to specify library docs.

In this tutorial we have learn about the Rust Comments and its application with practical example. I hope you will like this tutorial.