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 - Constants 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 - 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 - 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 Conditionals in Rust Conditional Statements are the decision-making statements based on given conditions. Conditional statements are common in programming languages and rust has them and unlike many of them, the boolean condition doesn't need to be surrounded by parentheses but is better to use, and each condition is fo 3 min read Functions in Rust Functions are the block of reusable code that can perform similar related actions. You have already seen one of the most important functions in the language: the main function, which is the entry point of many programs. Youâve also seen the "fn" keyword, which allows you to declare new functions. Ru 4 min read Like