Rust - Comments Last Updated : 17 Oct, 2022 Comments Improve Suggest changes Like Article Like Report In Rust programming, a comment is a programmer-readable explanation or annotation in the source code of a computer program. Comments are statements that are not executed by the compiler and interpreter. To write comments in Rust, we have two types of comments as in any other programming language. Non-doc CommentsSingle-Line CommentsMultiLine CommentsDoc CommentsOuter doc comments Inner doc commentsSingle-Line Comments:To write single-lined comments we can use the // characters before the text you want to ignore while compiling and running. Example 1: Rust // Rust code for a single line comment fn main() { println!("Hello, world!"); //this text is ignored } Output: As we can the code inside the comment was not complied with and hence didn't generate any error. Multi-line comments:Using multi-line comments we can ignore multiple lines in the source code file. We begin the comment with /* and end the comment with */ Example 2: Rust // Rust code for Multiline comments fn main() { println!("Hello, world!"); /* this is a Multiline comment */ println!("Hello, Geeks!") } Output: Doc comments:Rust also has doc comments which can be used to document a particular entity in the source code, that can be a function, struct, or any other entity. We can use as follows: Outer doc commentsInner doc commentsOuter Doc comments: We use outer doc comments to document some code outside the block. It helps in knowing the high-level overview of the entity in the code. Example 3: Rust // Rust code for main function // simply prints hello geeks fn main() { println!("Hello, Geeks!") } Output: Inner Doc comments:The inner documentation comment can be used to get fine-grain documentation inside the block of code. This can be used with //! Example 4: Rust // Rust code for inner doc comments fn main() { greet() } /// greet function simply prints hello geeks fn greet(){ //! This is a simple greet println!("Hello, Geeks!") } Output: Comment More infoAdvertise with us Next Article Rust - Generics M meetgor Follow Improve Article Tags : Rust Rust-basics Similar Reads Rust - Conventions In Rust, there are certain conventions that need to be followed when we are creating dependencies. There are dependencies on libraries in Rust. Cargo! is a dependency manager in Rust that is similar to npm (in JavaScript) and pip (in Python). All the project dependencies are handled by cargo. For in 2 min read Rust - Constants Constants are the value that can not be changed after assigning them. If we created a constant, then there is no way of changing its value. The keyword for declaring constant is const. In Rust, constants must be explicitly typed. Â The below syntax is used to initialize a constant value: Syntax : con 1 min read Rust - Operators Operators in general are used to perform operations on values and variables. These are standard symbols used for the purpose of logical and arithmetic operations. In this article, we will look into different types of Rust operators. Operators tell the compiler or interpreter to perform a specific ma 9 min read Rust - Enum An enum in Rust is a custom data type that represents data that can be anyone among several possible variants. Each variant in the enum can optionally have data associated with it. An enumerated type is defined using the enum keyword before the name of the enumeration. It also consists of methods. S 3 min read Rust - Generics Generics in Rust is a method of generalizing data types. Generics are always defined at run time. As generics can have multiple forms over given parameters and can be applied to methods, functions, structures, traits, etc they are often referred to as parametric polymorphism in type theory. Generics 2 min read Rust - dead_code lint Rust is a systems programming language that has some unique features which include warning if there are unused variables or unused functions. To do this, the Rust compiler provides the users with a dead code lint which warns us about unused codes, and by the usage of the #[allow(dead_code)], it elim 1 min read Like