From the course: Rust Essential Training
Unlock the full course today
Join today to access over 22,400 courses taught by industry experts or purchase this course individually.
Adding comments - Rust Tutorial
From the course: Rust Essential Training
Adding comments
- [Instructor] When you're writing code, you're not just writing it for the compiler, You also need to be able to understand your code, as do other programmers that might inherit it later on. So it can be useful to include notes for yourself and those other programmers to explain things like what a particular section of code does. Or why you made certain design decisions. And you can do that by embedding comments in the source code. The syntax for comments in Rust is similar to languages like Java and C++. To insert a single line comment, we write two forward slashes followed by our message. Let's label this program as my hello world program. The compiler will ignore everything to the right of the double slashes until the end of the line. Code editors with syntax coloring often use green by default to indicate comments as shown here. Though if you prefer something else, most code editors will allow you to configure the…
Practice while you learn with exercise files
Download the files the instructor uses to teach the course. Follow along and learn by watching, listening and practicing.